3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-27 10:27:49 +02:00

Moved advanced example to subfolder. Added basic example.

This commit is contained in:
Björn Ritzl 2021-04-26 22:47:37 +02:00
parent a19bdd78e8
commit 398e78670f
31 changed files with 551 additions and 24 deletions

View File

@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"about\"\n" " id: \"about\"\n"
" component: \"/example/about.gui\"\n" " component: \"/example/advanced/about.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"

View File

@ -1,4 +1,4 @@
script: "/example/about.gui_script" script: "/example/advanced/about.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -1,4 +1,4 @@
name: "example" name: "advanced"
scale_along_z: 0 scale_along_z: 0
embedded_instances { embedded_instances {
id: "menu" id: "menu"
@ -35,7 +35,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionfactory\"\n" " id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n" " type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/menu.collection\\\"\\n" " data: \"prototype: \\\"/example/advanced/menu.collection\\\"\\n"
"load_dynamically: true\\n" "load_dynamically: true\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"
@ -72,7 +72,7 @@ embedded_instances {
id: "main" id: "main"
data: "components {\n" data: "components {\n"
" id: \"main\"\n" " id: \"main\"\n"
" component: \"/example/main.script\"\n" " component: \"/example/advanced/advanced.script\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"
@ -87,7 +87,7 @@ embedded_instances {
"}\n" "}\n"
"components {\n" "components {\n"
" id: \"gui\"\n" " id: \"gui\"\n"
" component: \"/example/debug.gui\"\n" " component: \"/example/advanced/debug.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"
@ -148,7 +148,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionproxy\"\n" " id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n" " type: \"collectionproxy\"\n"
" data: \"collection: \\\"/example/pregame.collection\\\"\\n" " data: \"collection: \\\"/example/advanced/pregame.collection\\\"\\n"
"exclude: false\\n" "exclude: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"
@ -211,7 +211,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionproxy\"\n" " id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n" " type: \"collectionproxy\"\n"
" data: \"collection: \\\"/example/game.collection\\\"\\n" " data: \"collection: \\\"/example/advanced/game.collection\\\"\\n"
"exclude: false\\n" "exclude: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"
@ -294,7 +294,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionproxy\"\n" " id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n" " type: \"collectionproxy\"\n"
" data: \"collection: \\\"/example/about.collection\\\"\\n" " data: \"collection: \\\"/example/advanced/about.collection\\\"\\n"
"exclude: false\\n" "exclude: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"
@ -372,7 +372,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionproxy\"\n" " id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n" " type: \"collectionproxy\"\n"
" data: \"collection: \\\"/example/confirm.collection\\\"\\n" " data: \"collection: \\\"/example/advanced/confirm.collection\\\"\\n"
"exclude: false\\n" "exclude: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"
@ -430,7 +430,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionfactory\"\n" " id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n" " type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/background.collection\\\"\\n" " data: \"prototype: \\\"/example/advanced/background.collection\\\"\\n"
"load_dynamically: false\\n" "load_dynamically: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"

View File

@ -11,4 +11,4 @@ function on_message(self, message_id, message, sender)
monarch.show(hash("background"), { no_stack = true }) monarch.show(hash("background"), { no_stack = true })
monarch.show(hash("menu")) monarch.show(hash("menu"))
end end
end end

View File

@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"confirm\"\n" " id: \"confirm\"\n"
" component: \"/example/confirm.gui\"\n" " component: \"/example/advanced/confirm.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"

View File

@ -1,4 +1,4 @@
script: "/example/confirm.gui_script" script: "/example/advanced/confirm.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -1,4 +1,4 @@
script: "/example/debug.gui_script" script: "/example/advanced/debug.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"game\"\n" " id: \"game\"\n"
" component: \"/example/game.gui\"\n" " component: \"/example/advanced/game.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"

View File

@ -1,4 +1,4 @@
script: "/example/game.gui_script" script: "/example/advanced/game.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"menu\"\n" " id: \"menu\"\n"
" component: \"/example/menu.gui\"\n" " component: \"/example/advanced/menu.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"
@ -80,7 +80,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionfactory\"\n" " id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n" " type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/popup.collection\\\"\\n" " data: \"prototype: \\\"/example/advanced/popup.collection\\\"\\n"
"load_dynamically: false\\n" "load_dynamically: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"

View File

@ -1,4 +1,4 @@
script: "/example/menu.gui_script" script: "/example/advanced/menu.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"popup\"\n" " id: \"popup\"\n"
" component: \"/example/popup.gui\"\n" " component: \"/example/advanced/popup.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"

View File

@ -1,4 +1,4 @@
script: "/example/popup.gui_script" script: "/example/advanced/popup.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"pregame\"\n" " id: \"pregame\"\n"
" component: \"/example/pregame.gui\"\n" " component: \"/example/advanced/pregame.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"

View File

@ -1,4 +1,4 @@
script: "/example/pregame.gui_script" script: "/example/advanced/pregame.gui_script"
fonts { fonts {
name: "example" name: "example"
font: "/assets/example.font" font: "/assets/example.font"

View File

@ -0,0 +1,153 @@
name: "basic"
scale_along_z: 0
embedded_instances {
id: "screen1"
data: "components {\n"
" id: \"screen_proxy\"\n"
" component: \"/monarch/screen_proxy.script\"\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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"screen1\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/example/basic/screen1.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
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
}
}
embedded_instances {
id: "basic"
data: "components {\n"
" id: \"basic\"\n"
" component: \"/example/basic/basic.script\"\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
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
}
}
embedded_instances {
id: "screen2"
data: "components {\n"
" id: \"screen_proxy\"\n"
" component: \"/monarch/screen_proxy.script\"\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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"screen2\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/example/basic/screen2.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
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
}
}

View File

@ -0,0 +1,12 @@
local monarch = require "monarch.monarch"
function init(self)
msg.post(".", "acquire_input_focus")
msg.post("#", "show_screen1")
end
function on_message(self, message_id, message, sender)
if message_id == hash("show_screen1") then
monarch.show("screen1")
end
end

View File

@ -0,0 +1,37 @@
name: "screen1"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"screen1\"\n"
" component: \"/example/basic/screen1.gui\"\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
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
}
}

131
example/basic/screen1.gui Normal file
View File

@ -0,0 +1,131 @@
script: "/example/basic/screen1.gui_script"
fonts {
name: "example"
font: "/assets/example.font"
}
background_color {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
nodes {
position {
x: 320.0
y: 568.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "showscreen2"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "SHOW SCREEN 2"
font: "example"
id: "text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "showscreen2"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 1.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512

View File

@ -0,0 +1,13 @@
local monarch = require "monarch.monarch"
function init(self)
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
if gui.pick_node(gui.get_node("showscreen2"), action.x, action.y) then
monarch.show("screen2")
end
end
end

View File

@ -0,0 +1,37 @@
name: "screen2"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"screen2\"\n"
" component: \"/example/basic/screen2.gui\"\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
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
}
}

131
example/basic/screen2.gui Normal file
View File

@ -0,0 +1,131 @@
script: "/example/basic/screen2.gui_script"
fonts {
name: "example"
font: "/assets/example.font"
}
background_color {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
nodes {
position {
x: 320.0
y: 568.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "backbutton"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "BACK"
font: "example"
id: "text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "backbutton"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 1.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512

View File

@ -0,0 +1,13 @@
local monarch = require "monarch.monarch"
function init(self)
msg.post(".", "acquire_input_focus")
end
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
if gui.pick_node(gui.get_node("backbutton"), action.x, action.y) then
monarch.back()
end
end
end