st_ui_building_selector:
st_def 0, ui_building_selector_update, st_ui_building_selector
+st_ui_building_selector_delay:
+ st_def CURSOR_MOVE_TIMER, st_null_fn, st_ui_building_selector
st_ui_buildung_selector_exit:
st_def 0, ui_building_selector_exit, st_cursor
#define UI_TEXT_SPRITE_0 shadow_oam+4
+ ; lookup table for
+ ; labels displayed when hovering
+ ; over a building
+ui_cursor_label_table:
+ dw STR_WAREHOUSE
+
; inits UI
ui_init:
call ui_draw
add a, OBJ_OFF_Y
ld [hl+], a
+ ld a, [ui_cursor_pos]
+ mul8 a
+ ld b, a ; b = curosr * 8
+
ld a, UI_CURSOR_BUILDING_BASE_X
add a, OBJ_OFF_X
+ ; add cursor pos * 8
+ add a, b
ld [hl+], a
ld a, CURSOR_TILE
ld [hl+], a
; TODO: print based on cursor location
- ld hl, STR_WAREHOUSE
+ ld a, [ui_cursor_pos]
+ sla a ; * 2
+ ld hl, ui_cursor_label_table
+ ld d, 0
+ ld e, a
+ add hl, de
+ push hl
+ pop de ; de = pointing to label ptr
+ ld a, [de]
+ ld l, a
+ inc de
+ ld a, [de]
+ ld h, a
+ ; hl = string ptr
+
ld b, 10
ld c, 10
ld de, UI_TEXT_SPRITE_0
ld bc, st_ui_buildung_selector_exit
ret
@not_select:
+
+ input_held BTNRIGHT
+ jr z, @not_right REL
+
+ ld a, [ui_cursor_pos]
+ inc a
+ ld [ui_cursor_pos], a
+
+ ld bc, st_ui_building_selector_delay
+ ret
+@not_right:
+
+ input_held BTNLEFT
+ jr z, @not_left REL
+
+ ld a, [ui_cursor_pos]
+ dec a
+ ld [ui_cursor_pos], a
+
+ ld bc, st_ui_building_selector_delay
+ ret
+@not_left:
+
ldnull bc
ret