diff --git a/game/modules/tome/class/GameState.lua b/game/modules/tome/class/GameState.lua index 69886c837da61213e99f65b3210ba7bf9899241f..d98c6494d70dbc56a8a813cabe0cfd18270cbe1b 100644 --- a/game/modules/tome/class/GameState.lua +++ b/game/modules/tome/class/GameState.lua @@ -565,6 +565,12 @@ function _M:checkDonation(back_insert) -- This is only called when something nice happens (like an achievement) -- We then check multiple conditions to make sure the player is in a good state of mind + -- If this is a reccuring donator, do not bother her/him + if profile.auth and tonumber(profile.auth.donated) and profile.auth.sub == "yes" then + print("Donation check: already a reccuring donator") + return + end + -- Dont ask often local last = profile.mod.donations and profile.mod.donations.last_ask or 0 local min_interval = 15 * 24 * 60 * 60 -- 1 month @@ -614,6 +620,7 @@ function _M:checkDonation(back_insert) -- Request money! Even a god has to eat :) profile:saveModuleProfile("donations", {last_ask=os.time()}) + if back_insert then game:registerDialogAt(Donation.new(), 2) else diff --git a/game/modules/tome/dialogs/Donation.lua b/game/modules/tome/dialogs/Donation.lua index cb9af2f3c1a9b4b5ca5e28855011fd7588316c5b..97936fbac57a473366e09d2cf201fb67ce6150c8 100644 --- a/game/modules/tome/dialogs/Donation.lua +++ b/game/modules/tome/dialogs/Donation.lua @@ -34,15 +34,28 @@ function _M:init(source) self.donation_source = source or "ingame" Dialog.init(self, "Donations", 500, 300) - local desc = Textzone.new{width=self.iw, auto_height=true, text=[[Hi, I am Nicolas (DarkGod), the maker of this game. + local desc + local recur = false + + if not profile.auth or not tonumber(profile.auth.donated) or tonumber(profile.auth.donated) <= 1 then + -- First time donation + desc = Textzone.new{width=self.iw, auto_height=true, text=[[Hi, I am Nicolas (DarkGod), the maker of this game. It is my dearest hope that you find my game enjoyable, and that you will continue to do so for many years to come! ToME is free and open-source and will stay that way, but that does not mean I can live without money, so I have come to disturb you here and now to ask for your kindness. If you feel that the (many) hours you have spent having fun were worth it, please consider making a donation for the future of the game. ]]} + else + -- Recurring donation + recur = true + desc = Textzone.new{width=self.iw, auto_height=true, text=[[Thank you for supporting ToME, your donation was greatly appreciated. +If you want to continue supporting ToME you are welcome to make a new donation or even a reccuring one which helps ensure the future of the game. +Thank you for your kindness!]]} + end + self.c_donate = Numberbox.new{title="Donation amount: ", number=10, max=1000, min=5, chars=5, fct=function() end} local euro = Textzone.new{auto_width=true, auto_height=true, text=[[€]]} - self.c_recur = Checkbox.new{title="Make it a recurring montly donation", default=false, fct=function() end} + self.c_recur = Checkbox.new{title="Make it a recurring montly donation", default=recur, fct=function() end} local ok = require("engine.ui.Button").new{text="Accept", fct=function() self:ok() end} local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancel() end}