Skip to content

Commit

Permalink
Improved menu
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Nov 16, 2023
1 parent e60d8e9 commit ba19d29
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 35 deletions.
10 changes: 8 additions & 2 deletions main/car/car.collection
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ embedded_instances {
" component: \"/assets/test.rivemodel\"\n"
" position {\n"
" x: 0.0\n"
" y: 254.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
Expand All @@ -36,6 +36,8 @@ embedded_instances {
" z: 0.0\n"
" w: 1.0\n"
" }\n"
" property_decls {\n"
" }\n"
"}\n"
"components {\n"
" id: \"main\"\n"
Expand All @@ -51,11 +53,13 @@ embedded_instances {
" z: 0.0\n"
" w: 1.0\n"
" }\n"
" property_decls {\n"
" }\n"
"}\n"
""
position {
x: 256.0
y: 256.0
y: 269.0
z: 0.0
}
rotation {
Expand Down Expand Up @@ -86,6 +90,8 @@ embedded_instances {
" z: 0.0\n"
" w: 1.0\n"
" }\n"
" property_decls {\n"
" }\n"
"}\n"
""
position {
Expand Down
10 changes: 6 additions & 4 deletions main/nested/nested.collection → main/lights/lights.collection
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "nested"
name: "lights"
instances {
id: "back"
prototype: "/main/menu/back.go"
Expand All @@ -23,8 +23,8 @@ scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"lights1\"\n"
" component: \"/main/nested/lights.rivemodel\"\n"
" id: \"lights\"\n"
" component: \"/main/lights/lights.rivemodel\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
Expand All @@ -36,11 +36,13 @@ embedded_instances {
" z: 0.0\n"
" w: 1.0\n"
" }\n"
" property_decls {\n"
" }\n"
"}\n"
""
position {
x: 480.0
y: 320.0
y: 270.0
z: 0.0
}
rotation {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
scene: "/main/nested/lights.rivescene"
scene: "/main/lights/lights.rivescene"
default_animation: "Animation 1"
material: "/defold-rive/assets/rivemodel.material"
blend_mode: BLEND_MODE_ALPHA
default_state_machine: ""
create_go_bones: false
artboard: ""
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scene: "/main/nested/lights.riv"
scene: "/main/lights/lights.riv"
atlas: "/defold-rive/assets/empty.atlas"
22 changes: 20 additions & 2 deletions main/loader.collection
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ embedded_instances {
" }\n"
"}\n"
"embedded_components {\n"
" id: \"nested\"\n"
" id: \"lights\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/main/nested/nested.collection\\\"\\n"
" data: \"collection: \\\"/main/lights/lights.collection\\\"\\n"
"exclude: false\\n"
"\"\n"
" position {\n"
Expand Down Expand Up @@ -181,6 +181,24 @@ embedded_instances {
" w: 1.0\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"takethis\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/main/takethis/takethis.collection\\\"\\n"
"exclude: false\\n"
"\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
"}\n"
""
position {
x: 0.0
Expand Down
30 changes: 15 additions & 15 deletions main/menu/menu.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ local dirtylarry = require "dirtylarry/dirtylarry"


local BUTTONS = {
"car",
"nested",
--"bones",
--"cursor",
--"state",
--"stroke",
"sophiahud",
"scifihud"
{ id = "car", text = "Car" },
{ id = "lights", text = "Lights" },
--{ id = "bones", text = "Bones" },
--{ id = "cursor", text = "Cursor" },
--{ id = "state", text = "State" },
{ id = "sophiahud", text = "Sophia" },
{ id = "scifihud", text = "Sci-fi" },
--{ id = "takethis", text = "Take This!" },
}
local COLUMNS = 3
local WIDTH = 220
Expand All @@ -18,13 +18,13 @@ local HEIGHT = 70
function init(self)
msg.post(".", "acquire_input_focus")
local node = gui.get_node("template/larrybutton")
for i,id in ipairs(BUTTONS) do
for i,btn in ipairs(BUTTONS) do
local clone = gui.clone_tree(node)
local larrylabel = clone[hash("template/larrylabel")]
local larrybutton = clone[hash("template/larrybutton")]
gui.set_id(larrylabel, id .. "/larrylabel")
gui.set_id(larrybutton, id .. "/larrybutton")
gui.set_text(larrylabel, id:upper())
gui.set_id(larrylabel, btn.id .. "/larrylabel")
gui.set_id(larrybutton, btn.id .. "/larrybutton")
gui.set_text(larrylabel, btn.text:upper())

local x = 280 + ((i - 1) % COLUMNS) * WIDTH
local y = 400 - math.floor((i - 1) / COLUMNS) * HEIGHT
Expand All @@ -38,9 +38,9 @@ local function show_screen(id)
end

function on_input(self, action_id, action)
for _,id in ipairs(BUTTONS) do
dirtylarry:button(id, action_id, action, function ()
show_screen(id)
for _,btn in ipairs(BUTTONS) do
dirtylarry:button(btn.id, action_id, action, function ()
show_screen(btn.id)
end)
end
end
14 changes: 4 additions & 10 deletions main/scifihud/scifihud.script
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
go.property("health", 100)
go.property("shield", 100)

function init(self)
msg.post(".", "acquire_input_focus")
go.animate("#", "health", go.PLAYBACK_LOOP_PINGPONG, 0, go.EASING_INOUTQUAD, 5)
go.animate("#", "shield", go.PLAYBACK_LOOP_PINGPONG, 0, go.EASING_INOUTQUAD, 4, 2)
end

function update(self, dt)
go.set("#hud", "Health", self.health)
go.set("#hud", "Shield", self.shield)
go.set("#hud", "Health", 100)
go.set("#hud", "Shield", 100)
go.animate("#hud", "Health", go.PLAYBACK_LOOP_PINGPONG, 0, go.EASING_INOUTQUAD, 5)
go.animate("#hud", "Shield", go.PLAYBACK_LOOP_PINGPONG, 0, go.EASING_INOUTQUAD, 4, 2)
end

function on_input(self, action_id, action)
Expand Down
Binary file added main/takethis/5639-11052-here-take-this.riv
Binary file not shown.
65 changes: 65 additions & 0 deletions main/takethis/takethis.collection
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "adpolice"
instances {
id: "back"
prototype: "/main/menu/back.go"
position {
x: 0.0
y: 0.0
z: 0.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale3 {
x: 1.0
y: 1.0
z: 1.0
}
}
scale_along_z: 0
embedded_instances {
id: "go"
data: "embedded_components {\n"
" id: \"rivemodel\"\n"
" type: \"rivemodel\"\n"
" data: \"scene: \\\"/main/takethis/takethis.rivescene\\\"\\n"
"default_animation: \\\"\\\"\\n"
"material: \\\"/defold-rive/assets/rivemodel.material\\\"\\n"
"blend_mode: BLEND_MODE_ALPHA\\n"
"default_state_machine: \\\"State Machine 1\\\"\\n"
"create_go_bones: false\\n"
"artboard: \\\"main\\\"\\n"
"\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
"}\n"
""
position {
x: 643.0
y: 479.0
z: 0.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale3 {
x: 1.0
y: 1.0
z: 1.0
}
}
2 changes: 2 additions & 0 deletions main/takethis/takethis.rivescene
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scene: "/main/takethis/5639-11052-here-take-this.riv"
atlas: "/defold-rive/assets/empty.atlas"

0 comments on commit ba19d29

Please sign in to comment.