Don't Starve Revision History Viewer

Comparing Six Feet Under (Rev 86935) to All's Well That Maxwell (Rev 88237)

screens/mainscreen.lua

12131415161718192021222324252627282930
local WorldGenScreen = require "screens/worldgenscreen" local PopupDialogScreen = require "screens/popupdialog" local PlayerHud = require "screens/playerhud" local OptionsScreen = require "screens/optionsscreen" local EmailSignupScreen = require "screens/emailsignupscreen" local LoadGameScreen = require "screens/loadgamescreen" local CreditsScreen = require "screens/creditsscreen" local ModsScreen = require "screens/modsscreen" local ControlsScreen = require "screens/controlsscreen" local MorgueScreen = require "screens/morguescreen" local menu_spacing = 70 local bottom_offset = 60 local MainScreen = Class(Screen, function(self, profile) Screen._ctor(self, "MainScreen") self.profile = profile
1213141516171819202122232425262728293031323334353637383940
local WorldGenScreen = require "screens/worldgenscreen" local PopupDialogScreen = require "screens/popupdialog" local PlayerHud = require "screens/playerhud" local EmailSignupScreen = require "screens/emailsignupscreen" local LoadGameScreen = require "screens/loadgamescreen" local CreditsScreen = require "screens/creditsscreen" local ModsScreen = require "screens/modsscreen" local BigPopupDialogScreen = require "screens/bigpopupdialog" local ControlsScreen = nil local OptionsScreen = nil if PLATFORM == "PS4" then ControlsScreen = require "screens/controlsscreen_ps4" OptionsScreen = require "screens/optionsscreen_ps4" else ControlsScreen = require "screens/controlsscreen" OptionsScreen = require "screens/optionsscreen" end local rcol = RESOLUTION_X/2 -200 local lcol = -RESOLUTION_X/2 +200 local bottom_offset = 60 local MainScreen = Class(Screen, function(self, profile) Screen._ctor(self, "MainScreen") self.profile = profile
313233343536373839
self.log = true self:AddEventHandler("onsetplayerid", function(...) self:OnSetPlayerID(...) end) self:DoInit() self.default_focus = self.menu end) function MainScreen:OnSetPlayerID(playerid) if self.playerid then self.playerid:SetString(STRINGS.UI.MAINSCREEN.GREETING.. " "..playerid)
4142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
self.log = true self:AddEventHandler("onsetplayerid", function(...) self:OnSetPlayerID(...) end) self:DoInit() self.menu.reverse = true self.default_focus = self.menu end) function MainScreen:DoInit( ) STATS_ENABLE = false TheFrontEnd:GetGraphicsOptions():DisableStencil() TheFrontEnd:GetGraphicsOptions():DisableLightMapComponent() TheInputProxy:SetCursorVisible(true) TheFrontEnd:GetSound():PlaySound("dontstarve/music/music_FE","FEMusic") if PLATFORM == "NACL" then TheSim:RequestPlayerID() end self.bg = self:AddChild(Image("images/ui.xml", "bg_plain.tex")) self.bg:SetTint(BGCOLOURS.RED[1],BGCOLOURS.RED[2],BGCOLOURS.RED[3], 1) self.bg:SetVRegPoint(ANCHOR_MIDDLE) self.bg:SetHRegPoint(ANCHOR_MIDDLE) self.bg:SetVAnchor(ANCHOR_MIDDLE) self.bg:SetHAnchor(ANCHOR_MIDDLE) self.bg:SetScaleMode(SCALEMODE_FILLSCREEN) self.fixed_root = self:AddChild(Widget("root")) self.fixed_root:SetVAnchor(ANCHOR_MIDDLE) self.fixed_root:SetHAnchor(ANCHOR_MIDDLE) self.fixed_root:SetScaleMode(SCALEMODE_PROPORTIONAL) --RIGHT COLUMN self.right_col = self.fixed_root:AddChild(Widget("right")) self.right_col:SetPosition(rcol, 0) self.menu = self.right_col:AddChild(Menu(nil, 70)) self.menu:SetPosition(0, -120, 0) self.menu:SetScale(.8) local submenuitems = { {text = STRINGS.UI.MAINSCREEN.NOTIFY, cb = function() self:EmailSignup() end}, {text=STRINGS.UI.MAINSCREEN.FORUM, cb= function() self:Forums() end} } self.submenu = self.right_col:AddChild(Menu(submenuitems, 70)) self.submenu:SetPosition(0, -300, 0) self.submenu:SetScale(.6) --center stuff self.shield = self.fixed_root:AddChild(Image("images/fepanels.xml", "panel_shield.tex")) self.shield:SetVRegPoint(ANCHOR_MIDDLE) self.shield:SetHRegPoint(ANCHOR_MIDDLE) self.banner = self.shield:AddChild(Image("images/ui.xml", "update_banner.tex")) self.banner:SetVRegPoint(ANCHOR_MIDDLE) self.banner:SetHRegPoint(ANCHOR_MIDDLE) self.banner:SetPosition(0, -210, 0) self.updatename = self.banner:AddChild(Text(BUTTONFONT, 30)) self.updatename:SetPosition(0,8,0) local suffix = "" if BRANCH == "dev" then suffix = " (internal)" elseif BRANCH == "staging" then suffix = " (preview)" end self.updatename:SetString(STRINGS.UI.MAINSCREEN.UPDATENAME .. suffix) self.updatename:SetColour(0,0,0,1) --LEFT COLUMN self.left_col = self.fixed_root:AddChild(Widget("left")) self.left_col:SetPosition(lcol, 0) self.motd = self.left_col:AddChild(Widget("motd")) self.motd:SetScale(.9,.9,.9) self.motd:SetPosition(0, RESOLUTION_Y/2-200, 0) --self.motd:Hide() self.motdbg = self.motd:AddChild( Image( "images/globalpanels.xml", "panel.tex" ) ) self.motdbg:SetScale(.75*.9,.75,.75) self.motd.motdtitle = self.motdbg:AddChild(Text(TITLEFONT, 50)) self.motd.motdtitle:SetPosition(0, 130, 0) self.motd.motdtitle:SetRegionSize( 350, 60) self.motd.motdtitle:SetString(STRINGS.UI.MAINSCREEN.MOTDTITLE) self.motd.motdtext = self.motd:AddChild(Text(NUMBERFONT, 30)) self.motd.motdtext:SetHAlign(ANCHOR_MIDDLE) self.motd.motdtext:SetVAlign(ANCHOR_MIDDLE) self.motd.motdtext:SetPosition(0, -10, 0) self.motd.motdtext:SetRegionSize( 250, 160) self.motd.motdtext:SetString(STRINGS.UI.MAINSCREEN.MOTD) self.motd.button = self.motd:AddChild(ImageButton()) self.motd.button:SetPosition(0, -130, 0) self.motd.button:SetScale(.8) self.motd.button:SetText(STRINGS.UI.MAINSCREEN.MOTDBUTTON) self.motd.button:SetOnClick( function() VisitURL("http://forums.kleientertainment.com/index.php?/topic/28171-halloween-mod-challenge/") end ) self.motd.motdtext:EnableWordWrap(true) self.wilson = self.left_col:AddChild(UIAnim()) self.wilson:GetAnimState():SetBank("corner_dude") self.wilson:GetAnimState():SetBuild("corner_dude") self.wilson:GetAnimState():PlayAnimation("idle", true) self.wilson:SetPosition(0,-370,0) local SHOW_PROMO = true if SHOW_PROMO then self.wilson:Kill() self.wilson = nil local function KickOffScreecherMod() KnownModIndex:Enable("screecher") KnownModIndex:Save() TheSim:Quit() end local PopupDialogScreen = require("screens/popupdialog") local ImageButton = require("widgets/imagebutton") self.promo = self.left_col:AddChild(ImageButton("images/fepanels.xml", "DS_Scary_button.tex", "DS_Scary_button-rollover.tex")) self.promo:SetPosition(30, -180, 0) local scale = 0.8 self.promo:SetScale(scale, scale, scale) self.promo:SetOnClick( function() if PLATFORM == "NACL" then TheFrontEnd:PushScreen(PopupDialogScreen(STRINGS.UI.MAINSCREEN.SCREECHER_NACL_DIALOG_TITLE, STRINGS.UI.MAINSCREEN.SCREECHER_NACL_DIALOG_TEXT, { {text=STRINGS.UI.MODSSCREEN.CANCEL, cb = function() TheFrontEnd:PopScreen() end}, {text=STRINGS.UI.MAINSCREEN.SCREECHER_NACL_OKAY, cb = function() VisitURL("http://www.dontstarvegame.com/chrome-version-retired") end }, })) else TheFrontEnd:PushScreen(PopupDialogScreen(STRINGS.UI.MAINSCREEN.SCREECHER_DIALOG_TITLE, STRINGS.UI.MAINSCREEN.SCREECHER_DIALOG_TEXT, { {text=STRINGS.UI.MODSSCREEN.CANCEL, cb = function() TheFrontEnd:PopScreen() end}, {text=STRINGS.UI.MODSSCREEN.RESTART, cb = function() KickOffScreecherMod() end }, })) end end) end if PLATFORM == "NACL" then self.playerid = self.fixed_root:AddChild(Text(NUMBERFONT, 35)) self.playerid:SetPosition(RESOLUTION_X/2 -400, RESOLUTION_Y/2 -60, 0) self.playerid:SetRegionSize( 600, 50) self.playerid:SetHAlign(ANCHOR_RIGHT) self.purchasebutton = self.right_col:AddChild(ImageButton("images/ui.xml", "special_button.tex", "special_button_over.tex")) self.purchasebutton:SetScale(.5,.5,.5) self.purchasebutton:SetPosition(0,200,0) self.purchasebutton:SetFont(BUTTONFONT) self.purchasebutton:SetTextSize(80) if not IsGamePurchased() then self.purchasebutton:SetOnClick( function() self:Buy() end) self.purchasebutton:SetText( STRINGS.UI.MAINSCREEN.BUYNOW ) else self.purchasebutton:SetOnClick( function() self:SendGift() end) self.purchasebutton:SetText( STRINGS.UI.MAINSCREEN.GIFT ) end end if PLATFORM ~= "NACL" and PLATFORM ~= "PS4" then self:UpdateMOTD() end --focus moving self.motd.button:SetFocusChangeDir(MOVE_RIGHT, self.menu) self.menu:SetFocusChangeDir(MOVE_LEFT, self.motd.button) self.submenu:SetFocusChangeDir(MOVE_LEFT, self.motd.button) self.menu:SetFocusChangeDir(MOVE_DOWN, self.submenu, -1) self.submenu:SetFocusChangeDir(MOVE_UP, self.menu, 1) if PLATFORM == "PS4" then self.submenu:Hide() self.motd:Hide() end self:MainMenu() self.menu:SetFocus() end function MainScreen:OnSetPlayerID(playerid) if self.playerid then self.playerid:SetString(STRINGS.UI.MAINSCREEN.GREETING.. " "..playerid)
454647484950515253545556
if not down and control == CONTROL_CANCEL then if not self.mainmenu then self:MainMenu() return true end end end function MainScreen:OnRawKey( key, down ) if not self.focus then return end
243244245246247248249250251252253254
if not down and control == CONTROL_CANCEL then if not self.mainmenu then self:MainMenu() return true end end end function MainScreen:OnRawKey( key, down ) if not self.focus then return end
62636465666768
elseif not SaveGameIndex:GetCurrentMode(1) then local function onsaved() StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = 1}) end SaveGameIndex:StartSurvivalMode(1, "wilson", {}, onsaved) else StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = 1})
260261262263264265266
elseif not SaveGameIndex:GetCurrentMode(1) then local function onsaved() StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = 1}) end SaveGameIndex:StartSurvivalMode(1, "wilson", {}, onsaved) else StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = 1})
70717273747576777879
return true elseif key >= KEY_1 and key <= KEY_7 then local level_num = key - KEY_1 + 1 local function onstart() StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = 1}) end SaveGameIndex:FakeAdventure(onstart, 1, level_num) return true elseif key == KEY_0 then
268269270271272273274275276277
return true elseif key >= KEY_1 and key <= KEY_7 then local level_num = key - KEY_1 + 1 local function onstart() StartNextInstance({reset_action=RESET_ACTION.LOAD_SLOT, save_slot = 1}) end SaveGameIndex:FakeAdventure(onstart, 1, level_num) return true elseif key == KEY_0 then
9899100101102103
end end function MainScreen:Buy() TheSim:SendJSMessage("MainScreen:Buy") TheFrontEnd:GetSound():KillSound("FEMusic")
296297298299300301302
end end -- NACL MENU OPTIONS function MainScreen:Buy() TheSim:SendJSMessage("MainScreen:Buy") TheFrontEnd:GetSound():KillSound("FEMusic")
116117118119120121122123124125126127128129130131132133134135136
TheSim:SendJSMessage("MainScreen:ProductKeys") end local function CheckTesting(fn) return function() if BRANCH == "staging" then TheFrontEnd:PushScreen(PopupDialogScreen(STRINGS.UI.MAINSCREEN.TESTING, STRINGS.UI.MAINSCREEN.TESTINGDETAIL,{ {text=STRINGS.UI.MAINSCREEN.TESTINGYES, cb = function() fn() end}, {text=STRINGS.UI.MAINSCREEN.TESTINGNO, cb = function() end} })) else fn() end end end function MainScreen:Settings() TheFrontEnd:PushScreen(OptionsScreen(false)) end
315316317318319320321322323324325326327328329330
TheSim:SendJSMessage("MainScreen:ProductKeys") end function MainScreen:Rate() TheSim:SendJSMessage("MainScreen:Rate") end function MainScreen:Logout() TheSim:SendJSMessage("MainScreen:Logout") end -- SUBSCREENS function MainScreen:Settings() TheFrontEnd:PushScreen(OptionsScreen(false)) end
147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
VisitURL("http://forums.kleientertainment.com/index.php?/forum/5-dont-starve/") end function MainScreen:Rate() TheSim:SendJSMessage("MainScreen:Rate") end function MainScreen:Logout() TheSim:SendJSMessage("MainScreen:Logout") end function MainScreen:Quit() TheFrontEnd:PushScreen(PopupDialogScreen(STRINGS.UI.MAINSCREEN.ASKQUIT, STRINGS.UI.MAINSCREEN.ASKQUITDESC, {{text=STRINGS.UI.MAINSCREEN.YES, cb = function() RequestShutdown() end },{text=STRINGS.UI.MAINSCREEN.NO, cb = function() TheFrontEnd:PopScreen() end} })) end local function get_timezone() local now = os.time() return os.difftime(now, os.time(os.date("!*t", now))) end local function GetDaysToUpdate() --require("date") local local_tz = get_timezone() local klei_tz = 28800--The time zone offset for vancouver local update_times = { os.time{year=2013, day=9, month=4, hour=13} - klei_tz, os.time{year=2013, day=18, month=4, hour=13} - klei_tz, os.time{year=2013, day=21, month=5, hour=13} - klei_tz, os.time{year=2013, day=11, month=6, hour=13} - klei_tz, os.time{year=2013, day=2, month=7, hour=13} - klei_tz, os.time{year=2013, day=26, month=7, hour=13} - klei_tz, -- modified for late release os.time{year=2013, day=20, month=8, hour=13} - klei_tz, os.time{year=2013, day=10, month=9, hour=13} - klei_tz, os.time{year=2013, day=1, month=10, hour=13} - klei_tz, os.time{year=2013, day=22, month=10, hour=13} - klei_tz, } table.sort(update_times) local build_time = TheSim:GetBuildDate() local last_build = build_time local now = os.time() - local_tz for k,v in ipairs(update_times) do if v > build_time then local seconds = v - now return math.ceil( (((seconds / 60) / 60) / 24) ), math.ceil( ((((now - last_build) / 60) / 60) / 24) ) else last_build = v end end end function MainScreen:OnExitButton() if PLATFORM == "NACL" then self:Logout()
341342343344345346347348349350
VisitURL("http://forums.kleientertainment.com/index.php?/forum/5-dont-starve/") end function MainScreen:Quit() TheFrontEnd:PushScreen(PopupDialogScreen(STRINGS.UI.MAINSCREEN.ASKQUIT, STRINGS.UI.MAINSCREEN.ASKQUITDESC, {{text=STRINGS.UI.MAINSCREEN.YES, cb = function() RequestShutdown() end },{text=STRINGS.UI.MAINSCREEN.NO, cb = function() TheFrontEnd:PopScreen() end} })) end function MainScreen:OnExitButton() if PLATFORM == "NACL" then self:Logout()
207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
self:Quit() end end function MainScreen:UpdateDaysUntil() local days_until, days_since = GetDaysToUpdate() if days_until and days_since then if days_since <= 1 then self.days_since_string = string.format(STRINGS.UI.MAINSCREEN.FRESHBUILD) else self.days_since_string = string.format(STRINGS.UI.MAINSCREEN.LASTBUILDDAYS, days_since) end if days_until <= 1 then self.days_until_string = string.format(STRINGS.UI.MAINSCREEN.NEXTBUILDIMMINENT) else self.days_until_string = string.format(STRINGS.UI.MAINSCREEN.NEXTUPDATEDAYS, days_until) end if days_until < 2 then self.daysuntilanim:GetAnimState():PlayAnimation("coming", true) elseif days_until < 7 then self.daysuntilanim:GetAnimState():PlayAnimation("about", true) else self.daysuntilanim:GetAnimState():PlayAnimation("fresh", true) end self.daysuntiltext:SetString( self.days_until_string) else self.daysuntilanim:Hide() self.daysuntiltext:Hide() end end function MainScreen:DoInit( ) TheFrontEnd:GetGraphicsOptions():DisableStencil() TheFrontEnd:GetGraphicsOptions():DisableLightMapComponent() TheFrontEnd:GetSound():PlaySound("dontstarve/music/music_FE","FEMusic") if PLATFORM == "NACL" then TheSim:RequestPlayerID() end self.bg = self:AddChild(Image("images/ui.xml", "bg_plain.tex")) self.bg:SetTint(BGCOLOURS.RED[1],BGCOLOURS.RED[2],BGCOLOURS.RED[3], 1) self.bg:SetVRegPoint(ANCHOR_MIDDLE) self.bg:SetHRegPoint(ANCHOR_MIDDLE) self.bg:SetVAnchor(ANCHOR_MIDDLE) self.bg:SetHAnchor(ANCHOR_MIDDLE) self.bg:SetScaleMode(SCALEMODE_FILLSCREEN) self.fixed_root = self:AddChild(Widget("root")) self.fixed_root:SetVAnchor(ANCHOR_MIDDLE) self.fixed_root:SetHAnchor(ANCHOR_MIDDLE) self.fixed_root:SetScaleMode(SCALEMODE_PROPORTIONAL) local left_buffer = 175 self.menu = self.fixed_root:AddChild(Menu(nil, -menu_spacing)) self.shield = self.fixed_root:AddChild(Image("images/fepanels.xml", "panel_shield.tex")) self.shield:SetVRegPoint(ANCHOR_MIDDLE) self.shield:SetHRegPoint(ANCHOR_MIDDLE) self.banner = self.shield:AddChild(Image("images/ui.xml", "update_banner.tex")) self.banner:SetVRegPoint(ANCHOR_MIDDLE) self.banner:SetHRegPoint(ANCHOR_MIDDLE) self.banner:SetPosition(0, -210, 0) self.updatename = self.banner:AddChild(Text(BUTTONFONT, 30)) self.updatename:SetPosition(0,8,0) local suffix = "" if BRANCH == "dev" then suffix = " (internal)" elseif BRANCH == "staging" then suffix = " (preview)" end self.updatename:SetString(STRINGS.UI.MAINSCREEN.UPDATENAME .. suffix) self.updatename:SetColour(0,0,0,1) --bottom left node - days until update indicator and sign up button self.bottom_left_stuff = self.fixed_root:AddChild(Widget("bl")) self.bottom_left_stuff:SetPosition(-RESOLUTION_X/2 + left_buffer, -RESOLUTION_Y/2 + 200, 0) self.signup_button = self.bottom_left_stuff:AddChild(ImageButton()) self.signup_button:SetPosition(0, -150, 0) self.signup_button:SetText(STRINGS.UI.MAINSCREEN.NOTIFY) self.signup_button:SetOnClick( function() self:EmailSignup() end ) --[[ self.forum_button = self.bottom_left_stuff:AddChild(ImageButton()) self.forum_button:SetPosition(200, -150, 0) self.forum_button:SetText(STRINGS.UI.MAINSCREEN.FORUM) self.forum_button:SetOnClick( function() self:Forums() end ) --]] self.daysuntilanim = self.bottom_left_stuff:AddChild(UIAnim()) self.daysuntilanim:GetAnimState():SetBuild("build_status") self.daysuntilanim:GetAnimState():SetBank("build_status") self.daysuntilanim:SetPosition(20,0,0) self.daysuntiltext = self.bottom_left_stuff:AddChild(Text(UIFONT, 30)) self.daysuntiltext:SetHAlign(ANCHOR_MIDDLE) self.daysuntiltext:SetPosition(0,-80,0) self.daysuntiltext:SetRegionSize( 200, 50 ) self.daysuntiltext:SetClickable(false) self:UpdateDaysUntil() self.motd = self.fixed_root:AddChild(Widget("motd")) self.motd:SetScale(.9,.9,.9) self.motd:SetPosition(-RESOLUTION_X/2+left_buffer, RESOLUTION_Y/2-200, 0) self.motdbg = self.motd:AddChild( Image( "images/globalpanels.xml", "panel.tex" ) ) self.motdbg:SetScale(.75*.9,.75,.75) self.motd.motdtitle = self.motdbg:AddChild(Text(TITLEFONT, 50)) self.motd.motdtitle:SetPosition(0, 130, 0) self.motd.motdtitle:SetRegionSize( 350, 60) self.motd.motdtitle:SetString(STRINGS.UI.MAINSCREEN.MOTDTITLE) self.motd.motdtext = self.motd:AddChild(Text(NUMBERFONT, 30)) self.motd.motdtext:SetHAlign(ANCHOR_MIDDLE) self.motd.motdtext:SetVAlign(ANCHOR_TOP) self.motd.motdtext:SetPosition(0, -20, 0) self.motd.motdtext:SetRegionSize( 250, 160) self.motd.motdtext:SetString(STRINGS.UI.MAINSCREEN.MOTD) self.motd.button = self.motd:AddChild(ImageButton()) self.motd.button:SetPosition(0, -100, 0) self.motd.button:SetText(STRINGS.UI.MAINSCREEN.MOTDBUTTON) self.motd.button:SetOnClick( function() VisitURL("http://forums.kleientertainment.com/index.php?/topic/28171-halloween-mod-challenge/") end ) self.motd.motdtext:EnableWordWrap(true) self.playerid = self.fixed_root:AddChild(Text(NUMBERFONT, 35)) self.playerid:SetPosition(RESOLUTION_X/2 -400, RESOLUTION_Y/2 -60, 0) self.playerid:SetRegionSize( 600, 50) self.playerid:SetHAlign(ANCHOR_RIGHT) if PLATFORM == "NACL" then self.purchasebutton = self.fixed_root:AddChild(ImageButton("images/ui.xml", "special_button.tex", "special_button_over.tex")) self.purchasebutton:SetScale(.5,.5,.5) self.purchasebutton:SetPosition(450,200,0) self.purchasebutton:SetFont(BUTTONFONT) self.purchasebutton:SetTextSize(80) if not IsGamePurchased() then self.purchasebutton:SetOnClick( function() self:Buy() end) self.purchasebutton:SetText( STRINGS.UI.MAINSCREEN.BUYNOW ) else self.purchasebutton:SetOnClick( function() self:SendGift() end) self.purchasebutton:SetText( STRINGS.UI.MAINSCREEN.GIFT ) end end --focus moving self.motd.button:SetFocusChangeDir(MOVE_DOWN, self.signup_button) self.motd.button:SetFocusChangeDir(MOVE_RIGHT, self.menu) self.signup_button:SetFocusChangeDir(MOVE_UP, self.motd.button) self.signup_button:SetFocusChangeDir(MOVE_RIGHT, self.menu, -1) --[[ self.forum_button:SetFocusChangeDir(MOVE_UP, self.motd.button) self.forum_button:SetFocusChangeDir(MOVE_RIGHT, self.menu, -1) self.forum_button:SetFocusChangeDir(MOVE_LEFT, self.signup_button) --]] local function left_from_menu() local focus = self:GetDeepestFocus(); local up_diff = math.abs(focus:GetPosition().y - self.motd.button:GetPosition().y) local down_diff = math.abs(focus:GetPosition().y - self.signup_button:GetPosition().y) return up_diff < down_diff and self.motd.button or self.signup_button end self.menu:SetFocusChangeDir(MOVE_LEFT, left_from_menu) self:MainMenu() self.menu:SetFocus() if PLATFORM == "PS4" then self.bottom_left_stuff:Hide() self.motd:Hide() end end function MainScreen:Refresh() self:MainMenu() TheFrontEnd:GetSound():PlaySound("dontstarve/music/music_FE","FEMusic")
352353354355356357
self:Quit() end end function MainScreen:Refresh() self:MainMenu() TheFrontEnd:GetSound():PlaySound("dontstarve/music/music_FE","FEMusic")
413414415416417418419420421422423424425
self.mainmenu = false self.menu:Clear() for k,v in ipairs(menu_items) do self.menu:AddItem(v.text, v.cb, v.offset) end --self.menu:SetPosition(500, 0, 0) self.menu:SetPosition(RESOLUTION_X/2 -200 ,-RESOLUTION_Y/2 + bottom_offset + menu_spacing * (#menu_items-1),0) self.menu:SetFocus() end
361362363364365366367368369370371
self.mainmenu = false self.menu:Clear() for k = #menu_items, 1, -1 do local v = menu_items[k] self.menu:AddItem(v.text, v.cb, v.offset) end self.menu:SetFocus() end
478479480481482483484485486487
TheFrontEnd:PushScreen( CreditsScreen() ) end function MainScreen:MorgueMenu() TheFrontEnd:GetSound():KillSound("FEMusic") TheFrontEnd:PushScreen( MorgueScreen() ) end function MainScreen:CheatMenu() local menu_items = {}
424425426427428429
TheFrontEnd:PushScreen( CreditsScreen() ) end function MainScreen:CheatMenu() local menu_items = {}
491492493494495496497498499
self:ShowMenu(menu_items) end function MainScreen:DoGenerateDEMOWorld() self.menu:Disable() StartNextInstance({reset_action=RESET_ACTION.DO_DEMO, save_slot = 1}) end function MainScreen:MainMenu()
433434435436437438439440441442443444445446447448449450451452
self:ShowMenu(menu_items) end function MainScreen:OnPlayButtonNACL() TheFrontEnd:PushScreen( PopupDialogScreen(STRINGS.UI.MAINSCREEN.PLAY_ON_STEAM, STRINGS.UI.MAINSCREEN.PLAY_ON_STEAM_DETAIL, { {text=STRINGS.UI.MAINSCREEN.NEWGO, cb = function() TheFrontEnd:PopScreen() TheSim:SendJSMessage("MainScreen:MoveToSteam") TheFrontEnd:GetSound():KillSound("FEMusic") end}, {text=STRINGS.UI.MAINSCREEN.LATER, cb = function() TheFrontEnd:PopScreen() TheFrontEnd:PushScreen(LoadGameScreen()) end} })) end function MainScreen:MainMenu()
501502503504505506507508509510511512513
local menu_items = {} local purchased = IsGamePurchased() if purchased then table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.PLAY, cb= function() TheFrontEnd:PushScreen(LoadGameScreen())end, offset = Vector3(0,20,0)}) else table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.PLAYDEMO, cb= function() self:DoGenerateDEMOWorld() end}) table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.ENTERPRODUCTKEY, cb= function() self:EnterKey() end}) end table.insert( menu_items, {text=STRINGS.UI.MORGUESCREEN.MORGUE, cb= function() self:MorgueMenu() end}) if MODS_ENABLED then table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.MODS, cb= function() self:OnModsButton() end})
454455456457458459460461462463464465466467468
local menu_items = {} local purchased = IsGamePurchased() if purchased then if PLATFORM == "NACL" then table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.PLAY, cb= function() self:OnPlayButtonNACL() end, offset = Vector3(0,20,0)}) else table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.PLAY, cb= function() TheFrontEnd:PushScreen(LoadGameScreen())end, offset = Vector3(0,20,0)}) end else table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.ENTERPRODUCTKEY, cb= function() self:EnterKey() end}) end if MODS_ENABLED then table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.MODS, cb= function() self:OnModsButton() end})
515516517518519520521522523524525
table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.OPTIONS, cb= function() self:DoOptionsMenu() end}) if PLATFORM ~= "PS4" then table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.FORUM, cb= function() self:Forums() end}) end if PLATFORM == "NACL" then table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.LOGOUT, cb= function() self:OnExitButton() end}) elseif PLATFORM ~= "PS4" then
470471472473474475476
table.insert(menu_items, {text=STRINGS.UI.MAINSCREEN.OPTIONS, cb= function() self:DoOptionsMenu() end}) if PLATFORM == "NACL" then table.insert( menu_items, {text=STRINGS.UI.MAINSCREEN.LOGOUT, cb= function() self:OnExitButton() end}) elseif PLATFORM ~= "PS4" then
529530531532
self.mainmenu = true end return MainScreen
480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
self.mainmenu = true end function MainScreen:OnBecomeActive() MainScreen._base.OnBecomeActive(self) if PLATFORM == "PS4" then local gOpts = TheFrontEnd:GetGraphicsOptions() local isAdjusted = gOpts:IsDisplayAreaAdjusted() local sawAdjustmentPopup = Profile:SawDisplayAdjustmentPopup() if (not isAdjusted and not sawAdjustmentPopup) then local function adjust() gOpts:AdjustDisplayArea() Profile:ShowedDisplayAdjustmentPopup() TheFrontEnd:PopScreen() -- pop after updating settings otherwise this dialog might show again! Profile:Save() end local function nothanks() Profile:ShowedDisplayAdjustmentPopup() TheFrontEnd:PopScreen() -- pop after updating settings otherwise this dialog might show again! Profile:Save() end local popup = BigPopupDialogScreen(STRINGS.UI.MAINSCREEN.ADJUST_DISPLAY_HEADER, STRINGS.UI.MAINSCREEN.ADJUST_DISPLAY_TEXT, { {text=STRINGS.UI.MAINSCREEN.YES, cb = adjust}, {text=STRINGS.UI.MAINSCREEN.NO, cb = nothanks} } ) TheFrontEnd:PushScreen(popup) end end end local anims = { scratch = 1, hungry = 1, eat = 1, } function MainScreen:OnUpdate(dt) self.timetonewanim = self.timetonewanim and self.timetonewanim - dt or 5 +math.random()*5 if self.timetonewanim < 0 and self.wilson then self.wilson:GetAnimState():PushAnimation(weighted_random_choice(anims)) self.wilson:GetAnimState():PushAnimation("idle", true) self.timetonewanim = 10 + math.random()*15 end end function MainScreen:SetMOTD(str, cache) --print("MainScreen:SetMOTD", str, cache) local status, motd = pcall( function() return json.decode(str) end ) --print("decode:", status, motd) if status and motd then if cache then TheSim:SetPersistentString("motd", str) end local platform_motd = nil if PLATFORM == "WIN32_STEAM" or PLATFORM == "LINUX_STEAM" or PLATFORM == "OSX_STEAM" then platform_motd = motd.steam else platform_motd = motd.standalone end --print("platform_motd", platform_motd) if platform_motd then if platform_motd.motd_title and string.len(platform_motd.motd_title) > 0 and platform_motd.motd_body and string.len(platform_motd.motd_body) > 0 then self.motd.motdtitle:SetString(platform_motd.motd_title) self.motd.motdtext:SetString(platform_motd.motd_body) if platform_motd.link_title and string.len(platform_motd.link_title) > 0 and platform_motd.link_url and string.len(platform_motd.link_url) > 0 then self.motd.button:SetText(platform_motd.link_title) self.motd.button:SetOnClick( function() VisitURL(platform_motd.link_url) end ) else self.motd.button:Hide() end else self.motd:Hide() end else self.motd:Hide() end end end function MainScreen:OnMOTDQueryComplete( result, isSuccessful, resultCode ) --print( "MainScreen:OnMOTDQueryComplete", result, isSuccessful, resultCode ) if isSuccessful and string.len(result) > 1 and resultCode == 200 then self:SetMOTD(result, true) end end function MainScreen:OnCachedMOTDLoad(load_success, str) --print("MainScreen:OnCachedMOTDLoad", load_success, str) if load_success and string.len(str) > 1 then self:SetMOTD(str, false) end TheSim:QueryServer( "http://www.dontstarvegame.com/hosted-files/game-motd/ds_motd.json", function(...) self:OnMOTDQueryComplete(...) end, "GET" ) end function MainScreen:UpdateMOTD() --print("MainScreen:UpdateMOTD()") TheSim:GetPersistentString("motd", function(...) self:OnCachedMOTDLoad(...) end) end return MainScreen