-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Newui style #2
Newui style #2
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,13 @@ local function make_localscore_elements(pack, level, level_options) | |
end | ||
end | ||
return flex:new({ | ||
label:new("Your Score:", { font_size = 16, wrap = true }), | ||
label:new(tostring(math.floor(score * 1000) / 1000), { font_size = 60, cutoff_suffix = "..." }), | ||
quad:new({ | ||
child_element = flex:new({ | ||
label:new("Your Score:", { font_size = 16, wrap = true }), | ||
label:new(tostring(math.floor(score * 1000) / 1000), { font_size = 60, cutoff_suffix = "..." }) | ||
}, { direction = "column", align_items = "stretch" }), | ||
style = { background_color = { 0, 0, 0, 0.7 }, border_color = { 0, 0, 0, 0.7 }, border_thickness = 5 } | ||
}) | ||
}, { direction = "column", align_items = "stretch" }) | ||
end | ||
|
||
|
@@ -47,13 +52,13 @@ local function make_options_elements(pack, level) | |
selections[selections_index], | ||
{ font_size = 30, style = { color = { 0, 0, 0, 1 } }, wrap = true } | ||
), | ||
style = { background_color = { 1, 1, 1, 1 }, border_color = { 1, 1, 1, 1 }, border_thickness = 5 }, | ||
style = { background_color = { 1, 1, 1, 1 }, border_color = { 0, 0, 0, 1 }, border_thickness = 5 }, | ||
selectable = true, | ||
selection_handler = function(self) | ||
if self.selected then | ||
self.border_color = { 0, 0, 1, 1 } | ||
else | ||
self.border_color = { 1, 1, 1, 1 } | ||
self.border_color = { 0, 0, 0, 1 } | ||
end | ||
end, | ||
click_handler = function(self) | ||
|
@@ -62,6 +67,7 @@ local function make_options_elements(pack, level) | |
selections[selections_index], | ||
{ font_size = 30, style = { color = { 0, 0, 0, 1 }, padding = 8 }, wrap = true } | ||
) | ||
self.background_color = { 1, 1, 0, 1 } | ||
self.element = update_element(selections_element, self, 1, self.element) | ||
level_options_selected = { difficulty_mult = selections[selections_index] } | ||
local score = flex:new({ | ||
|
@@ -81,7 +87,7 @@ local function make_level_element(pack, level, extra_info) | |
extra_info.composer = extra_info.composer or "no composer" | ||
local music = extra_info.song .. "\n" .. extra_info.composer | ||
local preview = level_preview:new(pack.game_version, pack.id, level.id, { style = { padding = 0 } }) | ||
local elem = quad:new({ | ||
local elem = quad:new({ | ||
child_element = flex:new({ | ||
quad:new({ | ||
child_element = preview, | ||
|
@@ -92,7 +98,7 @@ local function make_level_element(pack, level, extra_info) | |
label:new(level.name, { font_size = 40, wrap = true }), | ||
label:new(level.author, { font_size = 26, wrap = true }), | ||
}, { direction = "column", style = { padding = 5 } }), | ||
label:new(level.description, { font_size = 16, wrap = true }), -- future: use elements[2] to change this to only appear when selected | ||
label:new("", { font_size = 16, wrap = true }), -- the future is now! | ||
}, { direction = "column" }), | ||
--flex:new({label:new(music, { font_size = 30, wrap = true })}, { align_items = "end", direction = "column" }), | ||
}, { direction = "row" }), | ||
|
@@ -109,9 +115,16 @@ local function make_level_element(pack, level, extra_info) | |
if level_element_selected ~= self then | ||
local elems = self.parent.elements | ||
for i = 1, #elems do | ||
elems[i].background_color = { 0, 0, 0, 0.7 } | ||
if(elems[i] == self) then | ||
description = label:new(level.description, { font_size = 16, wrap = true }) | ||
self.background_color = { 0.5, 0.5, 0, 0.7 } | ||
else | ||
description = label:new("", { font_size = 16, wrap = true }) | ||
elems[i].background_color = { 0, 0, 0, 0.7 } | ||
end | ||
elems[i].element.elements[2].elements[2] = update_element(description, elems[i].element.elements[2], 2, elems[i].element.elements[2].elements[2]) | ||
end | ||
self.background_color = { 0.5, 0.5, 0, 0.7 } | ||
root.elements[2] = update_element(root.elements[2], root, 2, root.elements[2]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll probably replace this update_element function at some point as it is kind of messy, but for now this if fine ig. |
||
local score = flex:new({ | ||
make_localscore_elements(pack.id, level.id, { difficulty_mult = 1 }), | ||
make_options_elements(pack, level), | ||
|
@@ -149,15 +162,15 @@ local function make_pack_elements() | |
if #pack.levels > 0 then | ||
elements[#elements + 1] = quad:new({ | ||
child_element = label:new(pack.name, { font_size = 30, style = { color = { 0, 0, 0, 1 } }, wrap = true }), | ||
style = { background_color = { 1, 1, 1, 1 }, border_color = { 1, 1, 1, 1 }, border_thickness = 4 }, | ||
style = { background_color = { 1, 1, 1, 1 }, border_color = { 0, 0, 0, 1 }, border_thickness = 4 }, | ||
selectable = true, | ||
selection_handler = function(self) | ||
if self.selected then | ||
self.border_color = { 0, 0, 1, 1 } | ||
else | ||
self.border_color = { 1, 1, 1, 1 } | ||
end | ||
end, | ||
selection_handler = function(self) | ||
if self.selected then | ||
self.border_color = { 0, 0, 1, 0.7 } | ||
else | ||
self.border_color = { 0, 0, 0, 0.7 } | ||
end | ||
end, | ||
click_handler = function(self) | ||
for j = 1, #elements do | ||
elements[j].background_color = { 1, 1, 1, 1 } | ||
|
@@ -195,10 +208,8 @@ local function make_pack_elements() | |
) | ||
cache_folder_flex[pack.id] = update_element(levels, root, 2, last_levels) | ||
end | ||
if root.elements[2] ~= levels then | ||
levels.elements[1]:click(false) | ||
end | ||
root.elements[2] = levels | ||
levels.elements[1]:click(false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to keep the check, if you always autoclick on the first level when selecting a pack clicking on the pack again will start the first level. The check there is making it not autoclick if the level column is still the same. |
||
end | ||
}) | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to check for
== self
, you can just set all descriptions to "" and then set the current one outside the loop (micro optimization is useless anyway and it looks cleaner that way in my opinion).(And refer to my comment about description being shown or not)