Add texts text page

This commit is contained in:
Insality 2020-01-11 15:37:14 +05:00
parent 59c9dc8a9b
commit 41a820a1fb
5 changed files with 1075 additions and 8 deletions

View File

@ -21,7 +21,7 @@ function M.init(self, node, lang_id, no_adjust)
end
function M.raw_set(self, text)
function M.set_to(self, text)
self.last_locale = false
self.text:set_to(text)
end

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,46 @@
local druid = require("druid.druid")
local bounce_style = require("druid.styles.bounce.style")
local empty_style = require("druid.styles.empty.style")
local bounce_style = require("druid.styles.bounce.style")
local main_page = require("example.kenney.page.main")
local text_page = require("example.kenney.page.texts")
local function on_control_button(self, side)
print("Click on button side", side)
local pages = {
"main_page",
"texts_page"
}
local function on_control_button(self, delta)
self.page = self.page + delta
if self.page < 1 then
self.page = #pages
end
if self.page > #pages then
self.page = 1
end
self.header:translate(pages[self.page])
local node = gui.get_node("C_Anchor")
gui.animate(node, "position.x", (self.page-1) * -600, gui.EASING_OUTSINE, 0.2)
end
local function init_top_panel(self)
self.druid:new_button("button_left/button", on_control_button, "left")
self.druid:new_button("button_right/button", on_control_button, "right")
self.druid:new_button("button_left/button", on_control_button, -1)
self.druid:new_button("button_right/button", on_control_button, 1)
self.header = self.druid:new_locale("text_header", "main_page")
end
function init(self)
druid.set_default_style(empty_style)
druid.set_default_style(bounce_style)
self.druid = druid.new(self)
init_top_panel(self)
self.page = 1
main_page.setup_page(self)
text_page.setup_page(self)
end

View File

@ -4,6 +4,7 @@ local M = {}
local en = {
main_page = "Main page",
texts_page = "Text page",
ui_section_button = "Button",
ui_section_text = "Text",
ui_section_timer = "Timer",
@ -17,6 +18,7 @@ local en = {
local ru = {
main_page = "Основное",
texts_page = "Текст",
ui_section_button = "Кнопка",
ui_section_text = "Текст",
ui_section_timer = "Таймер",

View File

@ -0,0 +1,55 @@
local lang = require("example.kenney.lang")
local M = {}
local pivots = {
gui.PIVOT_CENTER,
gui.PIVOT_N,
gui.PIVOT_NE,
gui.PIVOT_E,
gui.PIVOT_SE,
gui.PIVOT_S,
gui.PIVOT_SW,
gui.PIVOT_W,
gui.PIVOT_NW
}
local function setup_texts(self)
self.druid:new_text("text_inline", "Simple inline text")
self.druid:new_text("text_multiline", "Simple multiline text with smth")
local anchoring = self.druid:new_text("text_anchoring", "Anchoring")
self.druid:new_text("text_no_adjust", "Without adjust size", true)
self.druid:new_locale("text_locale", "ui_text_example")
local big_text = "Check max size"
local width = self.druid:new_text("text_max_width", big_text)
local height = self.druid:new_text("text_max_height", big_text)
local pivot_index = 1
timer.delay(0.3, true, function()
anchoring:set_pivot(pivots[pivot_index])
pivot_index = pivot_index + 1
if pivot_index > #pivots then
pivot_index = 1
end
end)
timer.delay(0.2, true, function()
big_text = big_text .. " max"
width:set_to(big_text)
height:set_to(big_text)
if #big_text > 50 then
big_text = "Check max size"
end
end)
end
function M.setup_page(self)
setup_texts(self)
end
return M