Skip to content

Commit

Permalink
UI fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderv committed Apr 24, 2018
1 parent 455e927 commit d4a1f85
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 12 deletions.
4 changes: 2 additions & 2 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ function love.load()
v:addQuads()
end
Gamestate.registerEvents()
Gamestate.switch(scripts.states.dealHand)
scripts.helpers.gamerules.startTurn(STATE)
Gamestate.switch(scripts.states.menu)

if DEBUG then
local inspect = require "lib.inspect"
require "lib.lovebird".monfn = function()
Expand Down
15 changes: 8 additions & 7 deletions scripts/rendering/renderMapView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local function addHeli(buildingId)
end

local mapView = {}
mapView.draw = function(lowest)
mapView.draw = function(lowest, noExtras)
if DEBUG then require("lib.lovebird").update() end
local x, y = scripts.helpers.calculations.getCoordinatesFromScreenPosition(love.mouse.getPosition())
if y then
Expand Down Expand Up @@ -63,7 +63,7 @@ mapView.draw = function(lowest)
end
zf = keepTrack
end
if not (i == 0 and j == 0) and zf then
if not (i == 0 and j == 0) and zf then
objects[#objects + 1] = { position = { x = (b.x + i) * 64 + 32, y = (b.y + j) * 64, z = 0, r = 0 }, texture = "normalCursor" }
end
end
Expand Down Expand Up @@ -113,6 +113,7 @@ mapView.draw = function(lowest)
end
end
for k, v in ipairs(STATE.buildings) do

objects[#objects + 1] = { position = { x = v.x * 64 + 32, y = v.y * 64, z = 0, r = (v.x * 3 * v.y * 5) % 4 * math.pi / 2 }, texture = scripts.gameobjects.buildings[v.building].asset }
end
for i = -6 + math.floor(CAMERA.x / 64), 6 + math.floor(CAMERA.x / 64) do
Expand All @@ -126,11 +127,11 @@ mapView.draw = function(lowest)
love.graphics.scale(SCALING)
DRAWMAP(objects)
love.graphics.pop()

scripts.rendering.renderUI.renderBackdrop()
scripts.rendering.renderUI.drawCards(STATE, lowest)
scripts.rendering.renderUI.drawStats(STATE)

if not noExtras then
scripts.rendering.renderUI.renderBackdrop()
scripts.rendering.renderUI.drawCards(STATE, lowest)
scripts.rendering.renderUI.drawStats(STATE)
end
love.graphics.pop()
end
return mapView
13 changes: 12 additions & 1 deletion scripts/rendering/renderUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ R.drawCard = function(state, card, running, fromTheAir)
end
end
R.drawMessage = function(message)
love.graphics.setColor(15/16, 15/16, 15/16)
love.graphics.rectangle("fill", 300, 538, 766, 30)
love.graphics.setColor(0, 0, 0)
love.graphics.print(message, 320, 538)
love.graphics.setColor(1, 1, 1)
end
R.drawMessageDown = function(message)
love.graphics.setColor(15/16, 15/16, 15/16)
love.graphics.rectangle("fill", 300, 738, 766, 30)
love.graphics.setColor(0, 0, 0)
love.graphics.print(message, 320, 738)
love.graphics.setColor(1, 1, 1)
end
local iconOffset = function(index)
return 200 + (100 * index)
end
Expand Down Expand Up @@ -144,7 +152,10 @@ R.drawStats = function(state)
str = "Money is created by the employed population, and is used by buildings (Money per turn)."
end
if str ~= "" then
love.graphics.draw(ICONS.backdrop_top.image, 0, 30, 0, 1, 2)
love.graphics.setColor(15/16, 15/16, 15/16)
love.graphics.rectangle("fill", 0, 30, 1366, 60)


end
love.graphics.setColor(0, 0, 0)
love.graphics.print(str, 40, 45)
Expand Down
63 changes: 63 additions & 0 deletions scripts/states/menu.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
--
-- Created by IntelliJ IDEA.
-- User: nander
-- Date: 21/04/2018
-- Time: 14:54
-- To change this template use File | Settings | File Templates.
--
LOWEST = 0
local fonts = {}
local fontData = require "assets.fonts.settings"
for k, v in pairs(fontData) do
fonts[k] = love.graphics.newFont("assets/fonts/" .. v.font, v.size)
end
local menu = {} -- previously: Gamestate.new()
menu.name = "playCards"
function menu:enter(prev)
menu.prev = prev
end

function menu:draw()
local f = love.graphics.getFont()
love.graphics.setFont(fonts["title"])

scripts.rendering.renderMapView.draw(0, true)
love.graphics.print("Card Major", 500,180)
love.graphics.setFont(f)
scripts.rendering.renderUI.drawMessageDown("Click to start")

end

function menu:update(dt, b)
end

function menu:keypressed(key)

end

function menu:mousepressed(x, y, mouse_btn)
if mouse_btn == 1 then
STATE = {
properties = { population = 0, money = 50 },
buildings = {
{ x = 1, y = 1, building = "small_park" },
},
hand = {},
discardPile = { },
drawPile = {"small_office", "small_generator", "small_residential"},
currentTurnEffects = {},
cars = {},
helis = {},
}
Gamestate.switch(scripts.states.dealHand)
scripts.helpers.gamerules.startTurn(STATE)
end
end

function menu:mousereleased(x, y, mouse_btn)
end

function menu:wheelmoved(x, y)
end

return menu
4 changes: 2 additions & 2 deletions scripts/states/runCard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ effects.add_cost = {
end,
draw = function(card, index, time)
end,
duration = 1,
duration = 0,
small = false,
}
effects.add_card = {
Expand Down Expand Up @@ -101,7 +101,7 @@ function menu:update(dt, wait)
menu.time = menu.time + dt

if menu.showing == "costs" then
if menu.time > 1 then
if menu.time > 0.2 then
menu.time = 0
menu.item = 1
menu.showing = "effects"
Expand Down

0 comments on commit d4a1f85

Please sign in to comment.