Browse Source

fix some seed stuff

master
Nicholas Hayashi 3 years ago
parent
commit
717260f3f2
  1. 19
      lib/gui.lua
  2. 6
      main.lua
  3. BIN
      res/img/seed_colon_text.png
  4. 5
      src/game.lua

19
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"
)
}

6
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 = {

BIN
res/img/seed_colon_text.png

Before

Width: 376  |  Height: 40  |  Size: 3.8 KiB

After

Width: 110  |  Height: 50  |  Size: 762 B

5
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
}

Loading…
Cancel
Save