~stratagus/stratagus/main-menu

« back to all changes in this revision

Viewing changes to scripts/guichan.lua

  • Committer: Joris Dauphin
  • Date: 2011-03-03 12:48:22 UTC
  • Revision ID: joris.dauphin@gmail.com-20110303124822-ja4k30fqsebr9vgq
Add initial "working" default menu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--      (c) Copyright 2010      by Stratagus team
 
2
 
 
3
Load("scripts/widgets.lua")
 
4
Load("scripts/menus/options.lua")
 
5
Load("scripts/menus/credits.lua")
 
6
Load("scripts/menus/games.lua")
 
7
 
 
8
-- Default configurations -------
 
9
Widget:setGlobalFont(Fonts["stratagus-menu"])
 
10
 
 
11
-- Define the different menus ----------
 
12
 
 
13
local function BuildProgramStartMenu()
 
14
--  war1gus.playlist = { "music/Orc Briefing.ogg" }
 
15
--[[
 
16
  if not (IsMusicPlaying()) then
 
17
    PlayMusic("music/Orc Briefing.ogg")
 
18
  end
 
19
--]]
 
20
  local menu = StratagusMenu()
 
21
  local offx = (Video.Width - 640) / 2
 
22
  local offy = (Video.Height - 480) / 2
 
23
 
 
24
  local currentGame = "";
 
25
  
 
26
  if (stratagus.preferences.CurrentGame ~= nil) then
 
27
    -- Remove .lua
 
28
        currentGame = stratagus.preferences.CurrentGame
 
29
  end
 
30
 
 
31
  menu:addLabel("Stratagus V" .. GetStratagusVersion() .. "  " .. GetStratagusHomepage(), offx + 320, offy + 390 + 18*1)
 
32
  menu:addLabel("Copyright (c) 1998-2011 by The Stratagus Project", offx + 320, offy + 390 + 18*4)
 
33
 
 
34
  menu:addFullButton("Select ~!Game", "g", offx + 208, offy + 104 + 36*1, function() RunGamesMenu(); menu:stop(1) end)
 
35
  local playbutton = menu:addFullButton("~!Play " .. currentGame, "p", offx + 208, offy + 104 + 36*2, function() Load(stratagus.preferences.CurrentGame); menu:stop(0); end)
 
36
 
 
37
  menu:addFullButton("Preference ~!Options", "o", offx + 208, offy + 104 + 36*4, function() stratagus.RunPreferencesOptionsMenu(); menu:stop(1) end)
 
38
  menu:addFullButton("~!Sound Options", "s", offx + 208, offy + 104 + 36*5, function() RunSoundOptionsMenu(); menu:stop(1) end)
 
39
  menu:addFullButton("~!Video Options", "v", offx + 208, offy + 104 + 36*6, function() RunVideoOptionsMenu(); menu:stop(1) end)
 
40
  menu:addFullButton("S~!how Credits", "h", offx + 208, offy + 104 + 36*7, RunShowCreditsMenu)
 
41
  menu:addFullButton("E~!xit Program", "x", offx + 208, offy + 104 + 36*9, function() menu:stop() end)
 
42
 
 
43
  playbutton:setEnabled(stratagus.preferences.CurrentGame ~= nil)
 
44
 
 
45
  return menu:run()
 
46
end
 
47
 
 
48
function stratagus.RunProgramStartMenu()
 
49
  local continue = 1
 
50
 
 
51
  while continue == 1 do
 
52
    continue = BuildProgramStartMenu(menu)
 
53
  end
 
54
end
 
55
 
 
56
LoadGameFile = nil
 
57
 
 
58
stratagus.RunProgramStartMenu()