From bdc2e0ee9420eaf99ad9502ad061f124e17e00b8 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 6 Oct 2016 14:05:56 +0200 Subject: New empty menu for settings --- config/menusettings.lua | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 config/menusettings.lua (limited to 'config/menusettings.lua') diff --git a/config/menusettings.lua b/config/menusettings.lua new file mode 100644 index 0000000..fc7d62e --- /dev/null +++ b/config/menusettings.lua @@ -0,0 +1,7 @@ +local menu = ... + +local button = require "button" +local selector = require "selector" + +local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale() +local bx = width/2-29 -- cgit v1.1 From 35262a7245bcd9ebf937d07ab3326655d96e5d2e Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 6 Oct 2016 14:43:11 +0200 Subject: Fixed scaling of fullscreen menu in different ratios --- config/menusettings.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'config/menusettings.lua') diff --git a/config/menusettings.lua b/config/menusettings.lua index fc7d62e..380828d 100644 --- a/config/menusettings.lua +++ b/config/menusettings.lua @@ -5,3 +5,13 @@ local selector = require "selector" local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale() local bx = width/2-29 + +return { + button:new(menu) + :setText("Go back") + :setPosition(bx,117) + :set("active", function (self) + self.parent:load("menumain") + end) + , +} \ No newline at end of file -- cgit v1.1 From 73bcd524906c51d43b22b3ea68c64b38f130bea6 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 20 Dec 2016 06:02:05 +0100 Subject: I have no idea why I have put everything in one commit --- config/menusettings.lua | 96 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 3 deletions(-) (limited to 'config/menusettings.lua') diff --git a/config/menusettings.lua b/config/menusettings.lua index 380828d..1b19e84 100644 --- a/config/menusettings.lua +++ b/config/menusettings.lua @@ -2,16 +2,106 @@ local menu = ... local button = require "button" local selector = require "selector" +local element = require "element" local width, height = love.graphics.getWidth()/getRealScale(), love.graphics.getHeight()/getRealScale() local bx = width/2-29 -return { +local keys = {"Left", "Right", "Up", "Down", "Attack", "Jump"} + +local dimmer = element:new(menu) + :setPosition(width/2, 15) + :set("visible", false) + :set("currentControl", "Left") + :set("draw", function (self, scale) + if self.visible then + love.graphics.setColor(0, 0, 0, 210) + love.graphics.rectangle("fill",0,0,width*getRealScale(),height*getRealScale()) + love.graphics.setColor(120, 255, 120, 255) + love.graphics.printf("Press new key for: \n> " .. self.currentControl .. " <", (width/2-110)*scale, (height/2-4)*scale, 220, "center", 0, scale, scale) + love.graphics.setColor(255, 255, 255, 255) + end + end) + +-- CHANGER functions +local isEnabled = function (self) + if Controller.getSets()[self.setNumber()] and not self.inProgress then + return true + else + return false + end +end +local startChange = function (self) + dimmer:set("visible", true):set("currentControl", "Left") + self.parent.allowMove = false + self.inProgress = true + self.currentKey = 0 + self.newSet = {} +end +local controlreleased = function(self, set, action, key) + if self.inProgress then + if self.currentKey > 0 and self.currentKey < 7 then + table.insert(self.newSet, key) + dimmer:set("currentControl", keys[self.currentKey+1]) + end + if self.currentKey > 5 then + dimmer:set("visible", false) + self.parent.allowMove = true + self.inProgress = false + table.insert(self.newSet, Controller.sets[self.setNumber()][7]) + print(self.newSet[7]) + Settings.change(self.setNumber(), self.newSet[1], self.newSet[2], self.newSet[3], self.newSet[4], self.newSet[5], self.newSet[6], self.newSet[7]) + else + self.currentKey = self.currentKey + 1 + end + end +end + +local a = { + button:new(menu) + :setText("Keyboard 1") + :setPosition(bx,80) + :set("setNumber", function () return 1 end) + :set("isEnabled", isEnabled) + :set("controlreleased", controlreleased) + :set("stopChange", stopChange) + :set("active", startChange) + , + button:new(menu) + :setText("Keyboard 2") + :setPosition(bx,96) + :set("setNumber", function () return 2 end) + :set("isEnabled", isEnabled) + :set("controlreleased", controlreleased) + :set("stopChange", stopChange) + :set("active", startChange) + , + button:new(menu) + :setText("Gamepad 1") + :setPosition(bx,112) + :set("setNumber", function () return 3 end) + :set("isEnabled", isEnabled) + :set("controlreleased", controlreleased) + :set("stopChange", stopChange) + :set("active", startChange) + , + button:new(menu) + :setText("Gamepad 2") + :setPosition(bx,128) + :set("setNumber", function () return 4 end) + :set("isEnabled", isEnabled) + :set("controlreleased", controlreleased) + :set("stopChange", stopChange) + :set("active", startChange) + , button:new(menu) :setText("Go back") - :setPosition(bx,117) + :setPosition(bx,144) :set("active", function (self) self.parent:load("menumain") end) , -} \ No newline at end of file + dimmer +} + +return a \ No newline at end of file -- cgit v1.1