Showing
94 changed files
with
116 additions
and
46 deletions
... | ... | @@ -24,8 +24,10 @@ local Entity = require "engine.Entity" |
24 | 24 | local Dialog = require "engine.ui.Dialog" |
25 | 25 | local Image = require "engine.ui.Image" |
26 | 26 | local Textzone = require "engine.ui.Textzone" |
27 | +local Separator = require "engine.ui.Separator" | |
27 | 28 | local TextzoneList = require "engine.ui.TextzoneList" |
28 | 29 | local ListColumns = require "engine.ui.ListColumns" |
30 | +local VariableList = require "engine.ui.VariableList" | |
29 | 31 | local Button = require "engine.ui.Button" |
30 | 32 | local WebView = require "engine.ui.WebView" |
31 | 33 | |
... | ... | @@ -37,38 +39,52 @@ local bonus_vault_slots_tooltip = "For every purchase of #{italic}##GREY#%s#LAST |
37 | 39 | local coins_balance_text = "#{italic}##UMBER#Voratun Coins available from your donations: #ROYAL_BLUE#%d#{normal}#" |
38 | 40 | local coins_balance_tooltip = "For every donations you've ever made you have earned voratun coins. These can be spent purchasing expansions or options on the online store. This is the amount you have left, if your purchase total is below this number you'll instantly get your purchase validated, if not you'll need to donate some more first.\n#GOLD##{italic}#Thanks for your support, every little bit helps the game survive for years on!#{normal}#" |
39 | 41 | |
42 | +_M.force_ui_inside = "microtxn" | |
43 | + | |
40 | 44 | function _M:init(mode) |
41 | 45 | if not mode then mode = core.steam and "steam" or "te4" end |
42 | 46 | self.mode = mode |
43 | 47 | |
44 | - self.ui = "microtxn" | |
45 | - | |
46 | 48 | self.cart = {} |
47 | 49 | |
50 | + | |
48 | 51 | self.base_title_text = game.__mod_info.long_name.." #GOLD#Online Store#LAST#" |
49 | 52 | Dialog.init(self, self.base_title_text, game.w * 0.8, game.h * 0.8) |
50 | 53 | |
54 | + game.tooltip:generate() | |
55 | + | |
51 | 56 | self.categories_icons = { |
52 | - pay2die = Entity.new{image="/data/gfx/mtx/ui/category_pay2die.png"}, | |
53 | - community = Entity.new{image="/data/gfx/mtx/ui/category_community.png"}, | |
54 | - cosmetic = Entity.new{image="/data/gfx/mtx/ui/category_cosmetic.png"}, | |
55 | - misc = Entity.new{image="/data/gfx/mtx/ui/category_misc.png"}, | |
57 | + pay2die = "/data/gfx/microtxn-ui/category_pay2die.png", | |
58 | + community = "/data/gfx/microtxn-ui/category_community.png", | |
59 | + cosmetic = "/data/gfx/microtxn-ui/category_cosmetic.png", | |
60 | + misc = "/data/gfx/microtxn-ui/category_misc.png", | |
56 | 61 | } |
57 | - local in_cart_icon = Entity.new{image="/data/gfx/mtx/ui/in_cart.png"} | |
62 | + local in_cart_icon = Entity.new{image="/data/gfx/microtxn-ui/in_cart.png"} | |
63 | + -- local icon_frame = Entity.new{image="/data/gfx/microtxn-ui/icon_frame.png"} | |
58 | 64 | |
59 | 65 | self.list = {} |
60 | 66 | self.purchasables = {} |
61 | 67 | self.recap = {} |
62 | 68 | |
69 | + local vsep = Separator.new{dir="horizontal", size=self.ih - 10} | |
70 | + | |
63 | 71 | self.c_waiter = Textzone.new{auto_width=1, auto_height=1, text="#YELLOW#-- connecting to server... --"} |
64 | - self.c_list = ListColumns.new{width=self.iw - 350, height=self.ih, item_height=132, hide_columns=true, scrollbar=true, sortable=true, columns={ | |
65 | - {name="", width=100, display_prop="", direct_draw=function(item, x, y) | |
72 | + | |
73 | + self.c_list = VariableList.new{width=self.iw - 350 - vsep.w, max_height=self.ih, scrollbar=true, sortable=true, | |
74 | + direct_draw=function(item, x, y, get_size) | |
75 | + if get_size then return 132 end | |
66 | 76 | item.img:toScreen(nil, x+2, y+2, 128, 128) |
67 | - item.category_img:toScreen(nil, x+2+64+32, y+2+64+32, 32, 32) | |
68 | 77 | if self.cart[item.id_purchasable] and item.nb_purchase > 0 then in_cart_icon:toScreen(nil, x+2, y+2, 128, 128) end |
69 | 78 | item.txt:display(x+10+130, y+2 + (128 - item.txt.h) / 2, 0) |
70 | - end}, | |
71 | - }, list=self.list, all_clicks=true, fct=function(item, _, button) self:use(item, button) end, select=function(item, sel) self:onSelectItem(item) end} | |
79 | + end, | |
80 | + list=self.list, all_clicks=true, fct=function(item, _, button) self:use(item, button) end, select=function(item, sel) self:onSelectItem(item) end} | |
81 | + -- self.c_list = ListColumns.new{width=self.iw - 350 - vsep.w, height=self.ih, item_height=132, hide_columns=true, scrollbar=true, sortable=true, columns={ | |
82 | + -- {name="", width=100, display_prop="", direct_draw=function(item, x, y) | |
83 | + -- item.img:toScreen(nil, x+2, y+2, 128, 128) | |
84 | + -- if self.cart[item.id_purchasable] and item.nb_purchase > 0 then in_cart_icon:toScreen(nil, x+2, y+2, 128, 128) end | |
85 | + -- item.txt:display(x+10+130, y+2 + (128 - item.txt.h) / 2, 0) | |
86 | + -- end}, | |
87 | + -- }, list=self.list, all_clicks=true, fct=function(item, _, button) self:use(item, button) end, select=function(item, sel) self:onSelectItem(item) end} | |
72 | 88 | self.c_list.on_focus_change = function(_, v) if not v then game:tooltipHide() end end |
73 | 89 | |
74 | 90 | self.c_bonus_vault_slots = Textzone.new{has_box=true, width=340, auto_height=1, text=bonus_vault_slots_text:format(0), can_focus=true} |
... | ... | @@ -93,7 +109,7 @@ function _M:init(mode) |
93 | 109 | |
94 | 110 | self.c_do_purchase = Button.new{text="Purchase", fct=function() self:doPurchase() end} |
95 | 111 | |
96 | - self.c_recap = ListColumns.new{width=350, height=self.ih - self.c_do_purchase.h - math.max(self.c_bonus_vault_slots.h, self.c_coins_available.h), scrollbar=true, columns={ | |
112 | + self.c_recap = ListColumns.new{width=350, height=self.ih - self.c_do_purchase.h - 15 - math.max(self.c_bonus_vault_slots.h, self.c_coins_available.h), scrollbar=true, columns={ | |
97 | 113 | {name="Name", width=50, display_prop="recap_name"}, |
98 | 114 | {name="Price", width=35, display_prop="recap_price"}, |
99 | 115 | {name="Qty", width=15, display_prop="recap_qty"}, |
... | ... | @@ -109,15 +125,16 @@ function _M:init(mode) |
109 | 125 | local uis = { |
110 | 126 | {vcenter=0, hcenter=0, ui=self.c_waiter}, |
111 | 127 | {left=0, top=0, ui=self.c_list}, |
128 | + {left=self.c_list, top=0, ui=vsep}, | |
112 | 129 | {right=0, top=0, ui=self.c_recap}, |
113 | 130 | {right=0, bottom=0, ui=self.c_do_purchase}, |
114 | 131 | -- {left=0, top=0, ui=wv}, |
115 | 132 | } |
116 | 133 | -- Only show those for steam as te4.org purchases require already having a donation up |
117 | 134 | if mode == "steam" then |
118 | - uis[#uis+1] = {right=0, bottom=self.c_do_purchase, ui=self.c_bonus_vault_slots} | |
135 | + uis[#uis+1] = {right=0, bottom=self.c_do_purchase.h+15, ui=self.c_bonus_vault_slots} | |
119 | 136 | elseif mode == "te4" then |
120 | - uis[#uis+1] = {right=0, bottom=self.c_do_purchase, ui=self.c_coins_available} | |
137 | + uis[#uis+1] = {right=0, bottom=self.c_do_purchase.h+15, ui=self.c_coins_available} | |
121 | 138 | end |
122 | 139 | |
123 | 140 | self:loadUI(uis) |
... | ... | @@ -138,6 +155,13 @@ function _M:init(mode) |
138 | 155 | self:generateList() |
139 | 156 | end |
140 | 157 | |
158 | +function _M:unload() | |
159 | + game.tooltip:generate() | |
160 | +end | |
161 | + | |
162 | +-- function _M:innerDisplay(x, y, nb_keyframes) | |
163 | +-- end | |
164 | + | |
141 | 165 | function _M:checks() game:onTickEnd(function() |
142 | 166 | if not profile.auth then |
143 | 167 | game:unregisterDialog(self) |
... | ... | @@ -240,6 +264,8 @@ function _M:updateCart() |
240 | 264 | end |
241 | 265 | |
242 | 266 | function _M:doPurchase() |
267 | + if table.count(self.cart) == 0 then self:simplePopup("Cart", "Cart is empty!") return end | |
268 | + | |
243 | 269 | self.in_paying_ui = true |
244 | 270 | if core.steam then self:doPurchaseSteam() |
245 | 271 | else self:doPurchaseTE4() |
... | ... | @@ -459,8 +485,13 @@ function _M:generateList() |
459 | 485 | for _, res in ipairs(e.data.list) do |
460 | 486 | res.id_purchasable = res.id |
461 | 487 | res.nb_purchase = 0 |
462 | - res.img = Entity.new{image=res.image} | |
463 | - res.category_img = self.categories_icons[res.category or "misc"] or self.categories_icons.misc | |
488 | + res.img = Entity.new{ | |
489 | + image=res.image, | |
490 | + add_mos={ | |
491 | + {image="/data/gfx/microtxn-ui/icon_frame.png"}, | |
492 | + {image=self.categories_icons[res.category or "misc"] or self.categories_icons.misc}, | |
493 | + }, | |
494 | + } | |
464 | 495 | res.txt = TextzoneList.new{width=self.iw - 10 - 132 - 350, height=128, pingpong=20, scrollbar=true} |
465 | 496 | res.txt:switchItem(true, ("%s (%s)\n#SLATE##{italic}#%s#{normal}#"):format(res.name, self:currencyDisplay(res.price), res.desc)) |
466 | 497 | res.txt.pingpong = nil | ... | ... |
... | ... | @@ -27,6 +27,8 @@ local Button = require "engine.ui.Button" |
27 | 27 | |
28 | 28 | module(..., package.seeall, class.inherit(Dialog)) |
29 | 29 | |
30 | +_M.force_ui_inside = "microtxn" | |
31 | + | |
30 | 32 | function _M:init(mode) |
31 | 33 | if not mode then mode = core.steam and "steam" or "te4" end |
32 | 34 | self.mode = mode | ... | ... |
... | ... | @@ -353,6 +353,11 @@ end |
353 | 353 | title_shadow = true |
354 | 354 | |
355 | 355 | function _M:init(title, w, h, x, y, alpha, font, showup, skin) |
356 | + if self.force_ui_inside then | |
357 | + self._lastui = self.ui | |
358 | + Base:changeDefault(self.force_ui_inside) | |
359 | + end | |
360 | + | |
356 | 361 | self.title = title |
357 | 362 | self.alpha = self.alpha or 255 |
358 | 363 | if showup ~= nil then |
... | ... | @@ -407,9 +412,11 @@ function _M:init(title, w, h, x, y, alpha, font, showup, skin) |
407 | 412 | self.frame.title_y = conf.title_bar.y |
408 | 413 | self.frame.title_w = conf.title_bar.w |
409 | 414 | self.frame.title_h = conf.title_bar.h |
410 | - self.frame.b7 = self.frame.b7:gsub("dialogframe", "title_dialogframe") | |
411 | - self.frame.b8 = self.frame.b8:gsub("dialogframe", "title_dialogframe") | |
412 | - self.frame.b9 = self.frame.b9:gsub("dialogframe", "title_dialogframe") | |
415 | + if not conf.title_bar.no_gfx then | |
416 | + self.frame.b7 = self.frame.b7:gsub("dialogframe", "title_dialogframe") | |
417 | + self.frame.b8 = self.frame.b8:gsub("dialogframe", "title_dialogframe") | |
418 | + self.frame.b9 = self.frame.b9:gsub("dialogframe", "title_dialogframe") | |
419 | + end | |
413 | 420 | end |
414 | 421 | |
415 | 422 | self.uis = {} |
... | ... | @@ -501,6 +508,11 @@ function _M:generate() |
501 | 508 | _RIGHT = function() self:moveFocus(1) end, |
502 | 509 | } |
503 | 510 | self.key:addBind("SCREENSHOT", function() if type(game) == "table" and game.key then game.key:triggerVirtual("SCREENSHOT") end end) |
511 | + | |
512 | + if self._lastui then | |
513 | + Base:changeDefault(self._lastui) | |
514 | + self._lastui = nil | |
515 | + end | |
504 | 516 | end |
505 | 517 | |
506 | 518 | function _M:updateTitle(title) | ... | ... |
... | ... | @@ -32,7 +32,9 @@ function _M:init(t) |
32 | 32 | self.max_h = t.max_height |
33 | 33 | self.fct = t.fct |
34 | 34 | self.select = t.select |
35 | + self.direct_draw = t.direct_draw | |
35 | 36 | self.scrollbar = t.scrollbar |
37 | + self.all_clicks = t.all_clicks | |
36 | 38 | self.min_items_shown = t.min_items_shown or 3 |
37 | 39 | self.display_prop = t.display_prop or "name" |
38 | 40 | |
... | ... | @@ -58,22 +60,28 @@ function _M:generate() |
58 | 60 | local sh = 0 |
59 | 61 | local minh = 0 |
60 | 62 | for i, item in ipairs(self.list) do |
61 | - local color = item.color or {255,255,255} | |
62 | - local width = fw - self.frame_sel.b4.w - self.frame_sel.b6.w | |
63 | + local ifh = 0 | |
64 | + if not self.direct_draw then | |
65 | + local color = item.color or {255,255,255} | |
66 | + local width = fw - self.frame_sel.b4.w - self.frame_sel.b6.w | |
63 | 67 | |
64 | - local text = self.font:draw(item[self.display_prop], width, color[1], color[2], color[3]) | |
65 | - local fh = fh * #text + self.frame_sel.b8.w / 3 * 2 | |
68 | + local text = self.font:draw(item[self.display_prop], width, color[1], color[2], color[3]) | |
69 | + ifh = fh * #text + self.frame_sel.b8.w / 3 * 2 | |
66 | 70 | |
67 | - local texs = {} | |
68 | - for z, tex in ipairs(text) do | |
69 | - texs[z] = {t=tex._tex, tw=tex._tex_w, th = tex._tex_h, w=tex.w, h=tex.h, y = (z - 1) * self.font_h + self.frame_sel.b8.w / 3} | |
71 | + local texs = {} | |
72 | + for z, tex in ipairs(text) do | |
73 | + texs[z] = {t=tex._tex, tw=tex._tex_w, th = tex._tex_h, w=tex.w, h=tex.h, y = (z - 1) * self.font_h + self.frame_sel.b8.w / 3} | |
74 | + end | |
75 | + item.start_h = sh | |
76 | + item.fh = ifh | |
77 | + item._texs = texs | |
78 | + else | |
79 | + ifh = self.direct_draw(item, 0, sh, true) | |
80 | + item.start_h = sh | |
81 | + item.fh = ifh | |
70 | 82 | end |
71 | 83 | |
72 | - item.start_h = sh | |
73 | - item.fh = fh | |
74 | - item._texs = texs | |
75 | - | |
76 | - sh = sh + fh | |
84 | + sh = sh + ifh | |
77 | 85 | if i <= self.min_items_shown then minh = sh end |
78 | 86 | end |
79 | 87 | self.h = math.max(minh, math.min(self.max_h or 1000000, sh)) |
... | ... | @@ -81,7 +89,7 @@ function _M:generate() |
81 | 89 | |
82 | 90 | self.scroll_inertia = 0 |
83 | 91 | self.scroll = 0 |
84 | - if self.scrollbar then self.scrollbar = Slider.new{size=self.h, max=sh} end | |
92 | + if self.scrollbar then self.scrollbar = Slider.new{size=self.h, max=sh, ui=self.ui} end | |
85 | 93 | |
86 | 94 | self.mouse:registerZone(0, 0, self.w, self.h, function(button, x, y, xrel, yrel, bx, by, event) |
87 | 95 | self.last_input_was_keyboard = false |
... | ... | @@ -96,7 +104,7 @@ function _M:generate() |
96 | 104 | if self.sel and self.list[self.sel] then self.list[self.sel].focus_decay = self.focus_decay_max end |
97 | 105 | self.sel = i |
98 | 106 | self:onSelect() |
99 | - if button == "left" and event == "button" then self:onUse() end | |
107 | + if (self.all_clicks or button == "left") and event == "button" then self:onUse(button, event) end | |
100 | 108 | break |
101 | 109 | end |
102 | 110 | end |
... | ... | @@ -104,7 +112,7 @@ function _M:generate() |
104 | 112 | |
105 | 113 | -- Add UI controls |
106 | 114 | self.key:addBinds{ |
107 | - ACCEPT = function() self:onUse() end, | |
115 | + ACCEPT = function() self:onUse("left", "key") end, | |
108 | 116 | MOVE_UP = function() |
109 | 117 | if self.sel and self.list[self.sel] then self.list[self.sel].focus_decay = self.focus_decay_max end |
110 | 118 | self.sel = util.boundWrap(self.sel - 1, 1, self.max) self:onSelect() |
... | ... | @@ -116,12 +124,17 @@ function _M:generate() |
116 | 124 | } |
117 | 125 | end |
118 | 126 | |
119 | -function _M:onUse() | |
127 | +function _M:setList(list) | |
128 | + self.list = list | |
129 | + self:generate() | |
130 | +end | |
131 | + | |
132 | +function _M:onUse(button, event) | |
120 | 133 | local item = self.list[self.sel] |
121 | 134 | if not item then return end |
122 | 135 | self:sound("button") |
123 | - if item.fct then item:fct() | |
124 | - else self.fct(item, self.sel) end | |
136 | + if item.fct then item:fct(button, event) | |
137 | + else self.fct(item, self.sel, button, event) end | |
125 | 138 | end |
126 | 139 | |
127 | 140 | function _M:onSelect() |
... | ... | @@ -149,6 +162,7 @@ end |
149 | 162 | |
150 | 163 | function _M:display(x, y, nb_keyframes, screen_x, screen_y) |
151 | 164 | local by = y |
165 | + local display_y = 0 | |
152 | 166 | core.display.glScissor(true, screen_x, screen_y, self.w, self.h) |
153 | 167 | |
154 | 168 | if self.scrollbar then |
... | ... | @@ -183,11 +197,18 @@ function _M:display(x, y, nb_keyframes, screen_x, screen_y) |
183 | 197 | if item.focus_decay <= 0 then item.focus_decay = nil end |
184 | 198 | end |
185 | 199 | end |
186 | - for z, tex in pairs(item._texs) do | |
187 | - if self.text_shadow then self:textureToScreen(tex, x+1 + self.frame_sel.b4.w, y+1 + tex.y, 0, 0, 0, self.text_shadow) end | |
188 | - self:textureToScreen(tex, x + self.frame_sel.b4.w, y + tex.y) | |
200 | + if not self.direct_draw then | |
201 | + for z, tex in pairs(item._texs) do | |
202 | + if self.text_shadow then self:textureToScreen(tex, x+1 + self.frame_sel.b4.w, y+1 + tex.y, 0, 0, 0, self.text_shadow) end | |
203 | + self:textureToScreen(tex, x + self.frame_sel.b4.w, y + tex.y) | |
204 | + end | |
205 | + else | |
206 | + self.direct_draw(item, x + self.frame_sel.b4.w, y) | |
189 | 207 | end |
208 | + item.last_display_x = screen_x | |
209 | + item.last_display_y = screen_y + display_y | |
190 | 210 | y = y + item.fh |
211 | + display_y = display_y + item.fh | |
191 | 212 | end |
192 | 213 | |
193 | 214 | core.display.glScissor(false) | ... | ... |
game/modules/tome/data/gfx/microtxn-ui/9.png
0 → 100644

1.49 KB

1.8 KB

1.31 KB

1.83 KB

1.96 KB

1.42 KB

2 KB

1.17 KB

1.12 KB

1.18 KB

1.13 KB

1.1 KB

1.13 KB

1.18 KB

1.13 KB

1.18 KB

1.17 KB

1.11 KB

1.17 KB

1.13 KB

1.1 KB

1.12 KB

1.18 KB

1.12 KB

1.17 KB

4.56 KB

3.56 KB

3.43 KB

5.04 KB

48.1 KB

12.2 KB

48.7 KB

16.2 KB

3.95 KB

16.6 KB

64.8 KB

17.5 KB

65.7 KB

20.7 KB

38.4 KB

34.5 KB

37.1 KB

38.4 KB

33.6 KB

38.8 KB

3.32 KB

12.2 KB

2.41 KB

1.52 KB

1.94 KB

1.92 KB

1.17 KB

1.08 KB

1.15 KB

1.08 KB

1.06 KB

1.07 KB

1.17 KB

1.08 KB

1.16 KB

1.14 KB

1.08 KB

1.13 KB

1.07 KB

1.02 KB

1.08 KB

1.14 KB

1.07 KB

1.14 KB

6.13 KB

1.34 KB

1.48 KB

1.33 KB

1.22 KB

1.33 KB

1.52 KB

1.34 KB
... | ... | @@ -21,9 +21,9 @@ microtxn = { |
21 | 21 | frame_shadow = {x=15, y=15, a=0.5}, |
22 | 22 | frame_alpha = 1, |
23 | 23 | frame_darkness = 0.6, |
24 | - frame_ox1 = -60, | |
25 | - frame_ox2 = 60, | |
26 | - frame_oy1 = -60, | |
27 | - frame_oy2 = 60, | |
28 | --- title_bar = {x=0, y=-17, w=4, h=25}, | |
24 | + frame_ox1 = -128, | |
25 | + frame_ox2 = 128, | |
26 | + frame_oy1 = -155, | |
27 | + frame_oy2 = 165, | |
28 | + title_bar = {x=0, y=-65, w=4, h=25, no_gfx=true}, | |
29 | 29 | } |
\ No newline at end of file | ... | ... |
... | ... | @@ -31,6 +31,8 @@ local Map = require "engine.Map" |
31 | 31 | |
32 | 32 | module(..., package.seeall, class.inherit(Dialog)) |
33 | 33 | |
34 | +_M.force_ui_inside = "microtxn" | |
35 | + | |
34 | 36 | function _M:init(source) |
35 | 37 | self.donation_source = source or "ingame" |
36 | 38 | Dialog.init(self, "Donations", 600, 300) | ... | ... |
utils/use_steam_overlay.sh
0 → 100755
-
Please register or login to post a comment