diff --git a/lib/gui.lua b/lib/gui.lua index b2cfe98..1806bc2 100644 --- a/lib/gui.lua +++ b/lib/gui.lua @@ -99,7 +99,10 @@ end -- max number -- padding number -- validate function(string) -> bool --- onchange function(new_value) -> void +-- +-- font { +-- color vec4 +-- } -- } function gui_make_textfield( args @@ -107,10 +110,14 @@ function gui_make_textfield( local args = args or {} local position = args.position or vec2(0) local dimensions = args.dimensions or vec2(100, 40) + local max = args.max or math.floor(dimensions.x / 18) + local padding = args.padding or 6 local validate = args.validate or function(string) return true end + local font = args.font or { + color = vec4(1) + } + local width, height = dimensions.x, dimensions.y - local max = args.max or 10 - local padding = args.padding or 6 local half_width = width/2 local half_height = height/2 @@ -127,7 +134,7 @@ function gui_make_textfield( am.wait(am.delay(0.4)) cursor.color = vec4(0) am.wait(am.delay(0.4)) - cursor.color = vec4(0, 0, 0, 1) + cursor.color = font.color end end @@ -135,8 +142,8 @@ function gui_make_textfield( back_rect, front_rect, am.translate(position + vec2(-width/2 + padding, 0)) ^ am.group( - am.scale(2) ^ am.text("", vec4(0, 0, 0, 1), "left"), - (am.translate(0, -8) ^ am.line(vec2(0, 0), vec2(16, 0), 2, vec4(0, 0, 0, 1)):action(coroutine.create(blink_cursor))):tag"cursor" + am.scale(2) ^ am.text("", font.color, "left"), + (am.translate(0, -12) ^ am.line(vec2(0, 0), vec2(16, 0), 2, font.color):action(coroutine.create(blink_cursor))):tag"cursor" ) } diff --git a/main.lua b/main.lua index 9ae35f6..2caeec5 100644 --- a/main.lua +++ b/main.lua @@ -130,7 +130,7 @@ function main_scene(do_backdrop, do_logo) local position = vec2(0, win.top - 20 - TEXTURES.LOGO.height/2) local logo = am.translate(position) - ^ pack_texture_into_sprite(TEXTURES.LOGO, TEXTURES.LOGO.width, TEXTURES.LOGO.height) + ^ pack_texture_into_sprite(TEXTURES.LOGO) local selected = false logo:action(function(self) @@ -151,7 +151,7 @@ function main_scene(do_backdrop, do_logo) end local seed_textfield, get_seed_textfield_value = gui_make_textfield{ - position = vec2(win.left + 500, 50), + position = vec2(win.left + 190, 50), dimensions = vec2(90, 40), max = math.ceil(math.log(HEX_GRID_WIDTH * HEX_GRID_HEIGHT, 10)), validate = function(string) @@ -162,7 +162,7 @@ function main_scene(do_backdrop, do_logo) seed_textfield ) group:append( - am.translate(win.left + 220, 50) ^ pack_texture_into_sprite(TEXTURES.SEED_COLON_TEXT) + am.translate(win.left + 80, 50) ^ pack_texture_into_sprite(TEXTURES.SEED_COLON_TEXT) ) local main_scene_options = { diff --git a/res/img/seed_colon_text.png b/res/img/seed_colon_text.png index 2c48dd5..ca77aed 100644 Binary files a/res/img/seed_colon_text.png and b/res/img/seed_colon_text.png differ diff --git a/src/game.lua b/src/game.lua index 5219b03..c5c025d 100644 --- a/src/game.lua +++ b/src/game.lua @@ -57,7 +57,10 @@ local game_scene_menu_options = { texture = TEXTURES.QUIT_HEX, action = function() win:close() - end + end, + keys = { + "f4" + } }, false }