Skip to content

Commit

Permalink
Large font for UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Tomes committed Dec 19, 2023
1 parent 6605067 commit 79e5420
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
5 changes: 3 additions & 2 deletions main.ms
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ drawHUD = function(display, player)
// display.backColor = color.black

statusBar = "HP: {0} / {1} LVL: {2} XP: {3} / {4} world: {5}".fill([player.currentHP, player.maxHP, player.level, player.xp, player.xpToNextLevel, Service.world.currentLevel])
statusBar = statusBar + " " * (67 - statusBar.len)
statusBar = statusBar + " " * (constants.UI_DISPLAY_WIDTH - statusBar.len)

display.print(statusBar, 0, 39, color.white, color.black)
display.print(statusBar, 0, constants.UI_DISPLAY_YMAX, color.white, color.black)
display.print(" " * constants.UI_DISPLAY_WIDTH, 0, constants.UI_DISPLAY_HEIGHT, color.white, color.black)

Service.messages.update()
end function
Expand Down
8 changes: 8 additions & 0 deletions src/config/constants.ms
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ TILE_DISPLAY_HEIGHT = PIXEL_HEIGHT / TILE_SIZE
TILE_DISPLAY_XMAX = TILE_DISPLAY_WIDTH - 1
TILE_DISPLAY_YMAX = TILE_DISPLAY_HEIGHT - 1
TILE_INDEX_SOLID = 219

UI_FONT_WIDTH = 16
UI_FONT_HEIGHT = 24
UI_DISPLAY_WIDTH = PIXEL_WIDTH / UI_FONT_WIDTH
UI_DISPLAY_HEIGHT = PIXEL_HEIGHT / UI_FONT_HEIGHT
UI_DISPLAY_XMAX = UI_DISPLAY_WIDTH - 1
UI_DISPLAY_YMAX = UI_DISPLAY_HEIGHT - 1

2 changes: 1 addition & 1 deletion src/ui/ExamineWindow.ms
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end function

ExamineWindow.reset = function(entities)
list = self.generateList(entities)
self.selectList.init(Display.hud, rect.make(4, 4, constants.TILE_DISPLAY_WIDTH - 4 * 2, constants.TILE_DISPLAY_HEIGHT - 4 * 2))
self.selectList.init(Display.hud, rect.make(4, 4, constants.UI_DISPLAY_WIDTH - 4 * 2, constants.UI_DISPLAY_HEIGHT - 4 * 2))
self.selectList.reset(list)
end function

Expand Down
12 changes: 6 additions & 6 deletions src/ui/HeadsUpDisplay.ms
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ HeadsUpDisplay = {}

HeadsUpDisplay.initTiles = function(displayNumber)
display(displayNumber).mode = displayMode.tile
display(displayNumber).tileSet = file.loadImage("assets/OEM437_8.png")
display(displayNumber).tileSetTileSize = 8
display(displayNumber).cellSize = 16
display(displayNumber).extent = [constants.TILE_DISPLAY_WIDTH, constants.TILE_DISPLAY_HEIGHT]
display(displayNumber).tileSet = file.loadImage("assets/OEM437_24_ex.png")
display(displayNumber).tileSetTileSize = [16, 24]
display(displayNumber).cellSize = [16, 24]
display(displayNumber).extent = [constants.UI_DISPLAY_WIDTH, constants.UI_DISPLAY_HEIGHT]
return display(displayNumber)
end function

Expand Down Expand Up @@ -37,8 +37,8 @@ HeadsUpDisplay.setCell = function(x, y, tile, color="#FFFFFF", backColor = "#000
end function

HeadsUpDisplay.clear = function()
for y in range(0, constants.TILE_DISPLAY_YMAX)
for x in range(0, constants.TILE_DISPLAY_XMAX)
for y in range(0, constants.UI_DISPLAY_YMAX)
for x in range(0, constants.UI_DISPLAY_XMAX)
self.setCell x, y, 0, color.black, color.clear
end for
end for
Expand Down
2 changes: 1 addition & 1 deletion src/ui/InventorySelectWindow.ms
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end function

InventorySelectWindow.reset = function(entity)
list = self.generateList(entity)
self.selectList.init(Display.hud, rect.make(4, 4, constants.TILE_DISPLAY_WIDTH - 4 * 2, constants.TILE_DISPLAY_HEIGHT - 4 * 2))
self.selectList.init(Display.hud, rect.make(4, 4, constants.UI_DISPLAY_WIDTH - 4 * 2, constants.UI_DISPLAY_HEIGHT - 4 * 2))
self.selectList.reset(list)
end function

Expand Down

0 comments on commit 79e5420

Please sign in to comment.