Commit d79e49ed39f8b3fec8a3ca888b770ab3276b5cd4

Authored by DarkGod
1 parent c25165f3

too long since I dusted it lol

... ... @@ -1979,6 +1979,9 @@ function _M:setupCommands()
1979 1979 -- Debug mode
1980 1980 self.key:addCommands{
1981 1981 [{"_d","ctrl"}] = function() if config.settings.cheat then
  1982 + package.loaded["mod.dialogs.Donation"] = nil
  1983 + self:registerDialog(require("mod.dialogs.Donation").new())
  1984 +do return end
1982 1985 local g = self.level.map(self.player.x, self.player.y, Map.TERRAIN)
1983 1986 print(g.define_as, g.image, g.z)
1984 1987 for i, a in ipairs(g.add_mos or {}) do print(" => ", a.image) end
... ...
... ... @@ -22,6 +22,7 @@ local Dialog = require "engine.ui.Dialog"
22 22 local Separator = require "engine.ui.Separator"
23 23 local List = require "engine.ui.List"
24 24 local Button = require "engine.ui.Button"
  25 +local ButtonImage = require "engine.ui.ButtonImage"
25 26 local Numberbox = require "engine.ui.Numberbox"
26 27 local Textzone = require "engine.ui.Textzone"
27 28 local Checkbox = require "engine.ui.Checkbox"
... ... @@ -32,12 +33,12 @@ module(..., package.seeall, class.inherit(Dialog))
32 33
33 34 function _M:init(source)
34 35 self.donation_source = source or "ingame"
35   - Dialog.init(self, "Donations", 500, 300)
  36 + Dialog.init(self, "Donations", 600, 300)
36 37
37 38 local desc
38 39 local recur = false
39 40
40   - if not profile.auth or not tonumber(profile.auth.donated) or tonumber(profile.auth.donated) <= 1 then
  41 + if not profile.auth or not tonumber(profile.auth.donated) or tonumber(profile.auth.donated) <= 1 or true then
41 42 local donation_features = { "#GOLD#Character cosmetic customization and special tiles#WHITE#", "#GOLD#Exploration mode (infinite lives)#WHITE#", "#GOLD#Item's appearance change (Shimmering)#WHITE#"}
42 43 self:triggerHook{"DonationDialog:features", list=donation_features}
43 44
... ... @@ -58,18 +59,24 @@ Thank you for your kindness!]]}
58 59 end
59 60
60 61 self.c_donate = Numberbox.new{title="Donation amount: ", number=10, max=1000, min=5, chars=5, fct=function() end}
  62 + self.c_recur = Checkbox.new{title="Monthly donation", default=recur, fct=function() end}
61 63 local euro = Textzone.new{auto_width=true, auto_height=true, text=[[euro]]}
62   - self.c_recur = Checkbox.new{title="Make it a recurring monthly donation", default=recur, fct=function() end}
63   - local ok = require("engine.ui.Button").new{text="Accept", fct=function() self:ok() end}
64   - local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancel() end}
  64 + local patreon = ButtonImage.new{alpha_unfocus=1, file="ui/patreon.png", fct=function() self:patreon() end}
  65 + local paypal = ButtonImage.new{alpha_unfocus=1, file="ui/paypal.png", fct=function() self:paypal() end}
  66 + local cancel = Button.new{text="Cancel", fct=function() self:cancel() end}
  67 + local patreon_explain = Textzone.new{width=patreon.w, auto_height=true, text=[[You can also make a pledge on Patreon if you prefer.]]}
  68 + local hsep = Separator.new{dir="horizontal", size=self.c_donate.h+paypal.h+self.c_recur.h-cancel.h}
65 69
66 70 self:loadUI{
67 71 {left=0, top=0, ui=desc},
68   - {left=5, bottom=5 + ok.h + self.c_recur.h, ui=self.c_donate},
69   - {left=5+self.c_donate.w, bottom=10 + ok.h + self.c_recur.h, ui=euro},
70   - {left=0, bottom=5 + ok.h, ui=self.c_recur},
71   - {left=0, bottom=0, ui=ok},
72   - {right=0, bottom=0, ui=cancel},
  72 + {left=5, bottom=5 + paypal.h + self.c_recur.h, ui=self.c_donate},
  73 + {left=5+self.c_donate.w, bottom=10 + paypal.h + self.c_recur.h, ui=euro},
  74 + {hcenter=0, bottom=cancel.h, ui=hsep},
  75 + {left=0, bottom=5 + paypal.h, ui=self.c_recur},
  76 + {right=0, bottom=5 + patreon.h, ui=patreon_explain},
  77 + {left=0, bottom=0, ui=paypal},
  78 + {right=0, bottom=0, ui=patreon},
  79 + {hcenter=0, bottom=0, ui=cancel},
73 80 }
74 81 self:setFocus(self.c_donate)
75 82 self:setupUI(false, true)
... ... @@ -79,7 +86,7 @@ function _M:cancel()
79 86 game:unregisterDialog(self)
80 87 end
81 88
82   -function _M:ok()
  89 +function _M:paypal()
83 90 if not tonumber(self.c_donate.number) or tonumber(self.c_donate.number) < 5 then return end
84 91
85 92 game:unregisterDialog(self)
... ... @@ -93,3 +100,10 @@ function _M:ok()
93 100 if inside then util.browserOpenUrl(url, {is_external=true})
94 101 else util.browserOpenUrl(url, {webview=true, is_external=true}) end
95 102 end
  103 +
  104 +function _M:patreon()
  105 + game:unregisterDialog(self)
  106 +
  107 + self:simplePopup("Thank you", "Thank you, a Patreon page should now open in your browser.")
  108 + util.browserOpenUrl("https://www.patreon.com/darkgodone", {is_external=true})
  109 +end
... ...