#78 Add text different adjust types

This commit is contained in:
Insality
2021-10-20 20:24:31 +03:00
parent a501d3418b
commit 4ef8316949
12 changed files with 1449 additions and 22 deletions

View File

@@ -240,7 +240,7 @@ embedded_instances {
}
}
embedded_instances {
id: "general_texts"
id: "texts_general"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.script\"\n"
@@ -257,7 +257,7 @@ embedded_instances {
" }\n"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"general_texts\"\n"
" value: \"texts_general\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
@@ -269,7 +269,7 @@ embedded_instances {
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/general/texts/texts.collection\\\"\\n"
" data: \"prototype: \\\"/example/examples/texts/texts_general/texts_general.collection\\\"\\n"
"load_dynamically: false\\n"
"\"\n"
" position {\n"
@@ -1121,3 +1121,66 @@ embedded_instances {
z: 1.0
}
}
embedded_instances {
id: "texts_adjust"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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: \"texts_adjust\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/texts/texts_adjust/texts_adjust.collection\\\"\\n"
"load_dynamically: 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

@@ -745,7 +745,7 @@ nodes {
}
nodes {
position {
x: -230.0
x: -240.0
y: -35.0
z: 0.0
w: 1.0
@@ -910,7 +910,7 @@ nodes {
}
nodes {
position {
x: 230.0
x: 240.0
y: -35.0
z: 0.0
w: 1.0
@@ -1093,7 +1093,7 @@ nodes {
w: 1.0
}
size {
x: 300.0
x: 360.0
y: 45.0
z: 0.0
w: 1.0

View File

@@ -38,6 +38,10 @@ local function init_top_panel(self)
sys.open_url("https://insality.github.io/druid/")
end)
-- self.button_code = self.druid:new_button("button_code/button", function()
-- sys.open_url("https://github.com/Insality/druid/blob/develop/example/examples/general/overview/overview.gui_script")
-- end)
self.text_header = self.druid:new_text("text_header", "Druid")
end
@@ -98,8 +102,6 @@ local function init_lobby(self)
self.lobby_grid:add(get_title(self, "General examples"))
self.lobby_grid:add(get_button(self, "Overview", "general_overview"))
self.lobby_grid:add(get_button(self, "Buttons", "general_buttons"))
self.lobby_grid:add(get_button(self, "Texts", "general_texts"))
self.lobby_grid:add(get_button_disabled(self, "Lang Text", "scene_name"))
self.lobby_grid:add(get_button(self, "Sliders", "general_sliders"))
self.lobby_grid:add(get_button(self, "Scrolls", "general_scroll"))
self.lobby_grid:add(get_button(self, "Grids", "general_grid"))
@@ -110,6 +112,11 @@ local function init_lobby(self)
self.lobby_grid:add(get_button_disabled(self, "Swipe", "scene_name"))
self.lobby_grid:add(get_button_disabled(self, "Drag", "scene_name"))
self.lobby_grid:add(get_title(self, "Texts"))
self.lobby_grid:add(get_button(self, "Texts", "texts_general"))
self.lobby_grid:add(get_button(self, "Adjust types", "texts_adjust"))
self.lobby_grid:add(get_button_disabled(self, "Lang Text", "texts_lang_text"))
self.lobby_grid:add(get_title(self, "Scrolls"))
self.lobby_grid:add(get_button_disabled(self, "Nested scrolls", "scroll_scene"))
self.lobby_grid:add(get_button_disabled(self, "With points of interest", "scroll_scene"))

View File

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

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,59 @@
local druid = require("druid.druid")
local const = require("druid.const")
function init(self)
self.druid = druid.new(self)
self.texts = {
self.druid:new_text("text_scale", nil, const.TEXT_ADJUST.DOWNSCALE),
self.druid:new_text("text_trim", nil, const.TEXT_ADJUST.TRIM),
self.druid:new_text("text_no_adjust", nil, const.TEXT_ADJUST.NO_ADJUST),
self.druid:new_text("text_scale_limited", nil, const.TEXT_ADJUST.DOWNSCALE_LIMITED)
:set_minimal_scale(0.5),
self.druid:new_text("text_scroll", nil, const.TEXT_ADJUST.SCROLL),
self.druid:new_text("text_scroll_scale", nil, const.TEXT_ADJUST.SCALE_THEN_SCROLL)
:set_minimal_scale(0.5)
}
local initial_texts = {}
local text_sizes = {}
for _, text in pairs(self.texts) do
initial_texts[text] = text.last_value
text_sizes[text] = 0
end
timer.delay(0.25, true, function()
for _, text in pairs(self.texts) do
local text_string = string.sub(initial_texts[text], 1, text_sizes[text])
text_sizes[text] = text_sizes[text] + 1
if text_sizes[text] > #initial_texts[text] then
text_sizes[text] = 0
end
text:set_to(text_string)
end
end)
end
function final(self)
self.druid:final()
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end

View File

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

View File

@@ -1,4 +1,4 @@
script: "/example/examples/general/texts/texts.gui_script"
script: "/example/examples/texts/texts_general/texts_general.gui_script"
fonts {
name: "game"
font: "/example/assets/fonts/game.font"

View File

@@ -1,4 +1,5 @@
local druid = require("druid.druid")
local const = require("druid.const")
local pivots = {
gui.PIVOT_CENTER,
@@ -17,7 +18,7 @@ local function setup_texts(self)
self.druid:new_text("text_inline")
self.druid:new_text("text_multiline")
local anchoring = self.druid:new_text("text_anchoring")
self.druid:new_text("text_no_adjust", "Without adjust size", true)
self.druid:new_text("text_no_adjust", "Without adjust size", const.TEXT_ADJUST.NO_ADJUST)
self.druid:new_lang_text("text_locale", "ui_text_example")
local big_text = "Check max size"