Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8051


Ignore:
Timestamp:
Mar 9, 2011, 11:27:05 AM (13 years ago)
Author:
dafrick
Message:

Merging latest changes in usability branch into tutorial branch.

Location:
code/branches/tutorial
Files:
52 edited

Legend:

Unmodified
Added
Removed
  • code/branches/tutorial

  • code/branches/tutorial/data/defaultConfig/keybindings.ini

    r7533 r8051  
    1919KeyDelete="scale 1 rotateRoll"
    2020KeyDivide=
    21 KeyDown="scale -1 moveFrontBack"
     21KeyDown="scale -1 moveFrontBack | navigateGUI down"
    2222KeyE="scale -1 rotateRoll"
    2323KeyEnd=boost
     
    4242KeyF9=
    4343KeyG=greet
    44 KeyGrave="openConsole"
     44KeyGrave="InGameConsole openConsole"
    4545KeyH=
    4646KeyHome=
     
    5252KeyKanji=
    5353KeyL=
    54 KeyLeft="scale -1 moveRightLeft"
     54KeyLeft="scale -1 moveRightLeft | navigateGUI left"
    5555KeyLeftAlt=
    5656KeyLeftBracket=
     
    9393KeyNumpadAdd=
    9494KeyNumpadComma=
    95 KeyNumpadEnter=
     95KeyNumpadEnter="navigateGUI enter"
    9696KeyNumpadEquals=
    9797KeyNumpadPeriod=
     
    108108KeyQ="scale 1 rotateRoll"
    109109KeyR="scale 1 moveUpDown"
    110 KeyReturn=
    111 KeyRight="scale 1 moveRightLeft"
     110KeyReturn="navigateGUI enter"
     111KeyRight="scale 1 moveRightLeft | navigateGUI right"
    112112KeyRightAlt=
    113113KeyRightBracket=
     
    126126KeyTab="NewHumanController changeMode"
    127127KeyU=""
    128 KeyUP="scale 1 moveFrontBack"
    129 KeyUnassigned="openConsole"
     128KeyUP="scale 1 moveFrontBack | navigateGUI up"
     129KeyUnassigned="InGameConsole openConsole"
    130130KeyUnderline=
    131131KeyUnlabeled=
  • code/branches/tutorial/data/gui/layouts/GraphicsMenu.layout

    r7801 r8051  
    1515            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    1616            <Property Name="VertFormatting" Value="TopAligned" />
    17             <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.2,0},{0.75,0},{0.6375,0}}" />
    18             <Window Type="MenuWidgets/StaticText" Name="orxonox/Resolution" >
    19                 <Property Name="Text" Value="Resolution" />
    20                 <Property Name="InheritsAlpha" Value="False" />
    21                 <Property Name="HorzFormatting" Value="HorzCentred" />
     17            <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.15,0},{0.75,0},{0.6375,0}}" />
     18            <Window Type="MenuWidgets/TabControl" Name="orxonox/GraphicsTabControl" >
     19                <Property Name="TabHeight" Value="{0,26.4388}" />
    2220                <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    23                 <Property Name="VertFormatting" Value="TopAligned" />
    24                 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.10,0},{0.475,0},{0.65,0}}" />
    25                 <Window Type="MenuWidgets/Listbox" Name="orxonox/ResolutionListbox" >
     21                <Property Name="TabPanePosition" Value="Top" />
     22                <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.925,0}}" />
     23                <Window Type="DefaultWindow" Name="orxonox/Display" >
     24                    <Property Name="Text" Value="Display" />
    2625                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    27                     <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.2,0},{0.95,0},{0.95,0}}" />
    28                     <Event Name="ItemSelectionChanged" Function="GraphicsMenu.GraphicsResolutionListbox_changed"/>
     26                    <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
     27                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/Resolution" >
     28                        <Property Name="Text" Value="Resolution" />
     29                        <Property Name="HorzFormatting" Value="HorzCentred" />
     30                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     31                        <Property Name="VertFormatting" Value="TopAligned" />
     32                        <Property Name="UnifiedAreaRect" Value="{{0.025,0},{0.035,0},{0.4875,0},{0.96,0}}" />
     33                        <Window Type="MenuWidgets/Checkbox" Name="orxonox/Display/Resolution/Fullscreen" >
     34                            <Property Name="Text" Value="Fullscreen" />
     35                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     36                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.15,0},{0.95,0},{0.27,0}}" />
     37                            <Event Name="CheckStateChanged" Function="GraphicsMenu.callback_FullscreenCheckbox_CheckStateChanged" />
     38                        </Window>
     39                        <Window Type="MenuWidgets/Combobox" Name="orxonox/Display/Resolution/Combobox" >
     40                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     41                            <Property Name="ClippedByParent" Value="False" />
     42                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.3,0},{0.95,0},{1.2,0}}" />
     43                            <Property Name="MaxEditTextLength" Value="1073741823" />
     44                            <Event Name="ListSelectionAccepted" Function="GraphicsMenu.callback_ResolutionCombobox_ListSelectionAccepted" />
     45                        </Window>
     46                        <Window Type="MenuWidgets/Editbox" Name="orxonox/Display/Resolution/EditboxWidth" >
     47                            <Property Name="MaxTextLength" Value="1073741823" />
     48                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     49                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.45,0},{0.45,0},{0.57,0}}" />
     50                            <Event Name="TextChanged" Function="GraphicsMenu.callback_ResolutionEditboxWidth_TextChanged" />
     51                        </Window>
     52                        <Window Type="MenuWidgets/Editbox" Name="orxonox/Display/Resolution/EditboxHeight" >
     53                            <Property Name="MaxTextLength" Value="1073741823" />
     54                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     55                            <Property Name="UnifiedAreaRect" Value="{{0.55,0},{0.45,0},{0.95,0},{0.57,0}}" />
     56                            <Event Name="TextChanged" Function="GraphicsMenu.callback_ResolutionEditboxHeight_TextChanged" />
     57                        </Window>
     58                        <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/Resolution/x" >
     59                            <Property Name="Text" Value="x" />
     60                            <Property Name="FrameEnabled" Value="False" />
     61                            <Property Name="HorzFormatting" Value="HorzCentred" />
     62                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     63                            <Property Name="UnifiedAreaRect" Value="{{0.45,0},{0.45,0},{0.55,0},{0.57,0}}" />
     64                            <Property Name="BackgroundEnabled" Value="False" />
     65                        </Window>
     66                        <Window Type="MenuWidgets/Button" Name="orxonox/Display/Resolution/Apply" >
     67                            <Property Name="Text" Value="Apply" />
     68                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     69                            <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.61,0},{0.75,0},{0.73,0}}" />
     70                            <Event Name="Clicked" Function="GraphicsMenu.callback_Apply_Clicked" />
     71                        </Window>
     72                        <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/Resolution/AspectRatioLabel" >
     73                            <Property Name="Text" Value="Aspect Ratio" />
     74                            <Property Name="FrameEnabled" Value="False" />
     75                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     76                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.825,0},{0.6,0},{0.95,0}}" />
     77                            <Property Name="BackgroundEnabled" Value="False" />
     78                        </Window>
     79                        <Window Type="MenuWidgets/Editbox" Name="orxonox/Display/Resolution/AspectRatio" >
     80                            <Property Name="Text" Value="1" />
     81                            <Property Name="MaxTextLength" Value="1073741823" />
     82                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     83                            <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.825,0},{0.95,0},{0.95,0}}" />
     84                        </Window>
     85                    </Window>
     86                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/Theme" >
     87                        <Property Name="Text" Value="Theme" />
     88                        <Property Name="HorzFormatting" Value="HorzCentred" />
     89                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     90                        <Property Name="VertFormatting" Value="TopAligned" />
     91                        <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.035,0},{0.975,0},{0.32,0}}" />
     92                        <Window Type="MenuWidgets/Combobox" Name="orxonox/Display/Theme/Combobox" >
     93                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     94                            <Property Name="ClippedByParent" Value="False" />
     95                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.5,0},{0.95,0},{1.6,0}}" />
     96                            <Property Name="MaxEditTextLength" Value="1073741823" />
     97                            <Event Name="ListSelectionAccepted" Function="GraphicsMenu.callback_ThemeCombobox_ListSelectionAccepted" />
     98                        </Window>
     99                    </Window>
     100                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/More" >
     101                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     102                        <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.37,0},{0.975,0},{0.7,0}}" />
     103                        <Window Type="MenuWidgets/Checkbox" Name="orxonox/Display/More/VSync" >
     104                            <Property Name="Text" Value="VSync" />
     105                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     106                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.1,0},{0.95,0},{0.45,0}}" />
     107                            <Event Name="CheckStateChanged" Function="GraphicsMenu.callback_VSyncCheckbox_CheckStateChanged" />
     108                        </Window>
     109                        <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/More/FSAALabel" >
     110                            <Property Name="Text" Value="FSAA" />
     111                            <Property Name="FrameEnabled" Value="False" />
     112                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     113                            <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.55,0},{0.3,0},{0.9,0}}" />
     114                            <Property Name="BackgroundEnabled" Value="False" />
     115                        </Window>
     116                        <Window Type="MenuWidgets/Combobox" Name="orxonox/Display/More/FSAA" >
     117                            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     118                            <Property Name="ClippedByParent" Value="False" />
     119                            <Property Name="UnifiedAreaRect" Value="{{0.3,0},{0.55,0},{0.95,0},{2.1,0}}" />
     120                            <Property Name="MaxEditTextLength" Value="1073741823" />
     121                            <Event Name="ListSelectionAccepted" Function="GraphicsMenu.callback_FSAACombobox_ListSelectionAccepted" />
     122                        </Window>
     123                    </Window>
     124                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/Notice" >
     125                        <Property Name="Font" Value="BlueHighway-12" />
     126                        <Property Name="Text" >Changing the theme, FSAA,
     127or VSync requires a restart</Property>
     128                        <Property Name="HorzFormatting" Value="HorzCentred" />
     129                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     130                        <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.75,0},{0.975,0},{0.96,0}}" />
     131                    </Window>
     132                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Display/NoticeRed" >
     133                        <Property Name="Font" Value="BlueHighway-12" />
     134                        <Property Name="Text" >Restart required</Property>
     135                        <Property Name="TextColours" Value="tl:FFFF0000 tr:FFFF8888 bl:FFFF8888 br:FFFFFFFF" />
     136                        <Property Name="HorzFormatting" Value="HorzCentred" />
     137                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     138                        <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.75,0},{0.975,0},{0.96,0}}" />
     139                    </Window>
     140                </Window>
     141                <Window Type="DefaultWindow" Name="orxonox/Settings" >
     142                    <Property Name="Text" Value="Settings" />
     143                    <Property Name="Visible" Value="False" />
     144                    <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     145                    <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
     146                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Settings/FovLabel" >
     147                        <Property Name="Text" Value="Vertical field of view (FOV)" />
     148                        <Property Name="FrameEnabled" Value="False" />
     149                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     150                        <Property Name="UnifiedAreaRect" Value="{{0.035,0},{0.05,0},{0.5,0},{0.12,0}}" />
     151                        <Property Name="BackgroundEnabled" Value="False" />
     152                    </Window>
     153                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Settings/FpsLimitLabel" >
     154                        <Property Name="Text" Value="Maximal frame rate" />
     155                        <Property Name="FrameEnabled" Value="False" />
     156                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     157                        <Property Name="UnifiedAreaRect" Value="{{0.035,0},{0.18,0},{0.5,0},{0.25,0}}" />
     158                        <Property Name="BackgroundEnabled" Value="False" />
     159                    </Window>
     160                    <Window Type="MenuWidgets/StaticText" Name="orxonox/Settings/ParticleLodLabel" >
     161                        <Property Name="Text" Value="Particle detail level" />
     162                        <Property Name="FrameEnabled" Value="False" />
     163                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     164                        <Property Name="UnifiedAreaRect" Value="{{0.035,0},{0.31,0},{0.5,0},{0.38,0}}" />
     165                        <Property Name="BackgroundEnabled" Value="False" />
     166                    </Window>
     167                    <Window Type="MenuWidgets/Editbox" Name="orxonox/Settings/Fov" >
     168                        <Property Name="MaxTextLength" Value="1073741823" />
     169                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     170                        <Property Name="UnifiedAreaRect" Value="{{0.5,0},{0.03,0},{0.65,0},{0.14,0}}" />
     171                    </Window>
     172                    <Window Type="MenuWidgets/Editbox" Name="orxonox/Settings/FpsLimit" >
     173                        <Property Name="MaxTextLength" Value="1073741823" />
     174                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     175                        <Property Name="UnifiedAreaRect" Value="{{0.5,0},{0.16,0},{0.65,0},{0.27,0}}" />
     176                    </Window>
     177                    <Window Type="MenuWidgets/Combobox" Name="orxonox/Settings/ParticleLodCombobox" >
     178                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     179                        <Property Name="ClippedByParent" Value="False" />
     180                        <Property Name="UnifiedAreaRect" Value="{{0.5,0},{0.29,0},{0.7,0},{0.725,0}}" />
     181                        <Property Name="MaxEditTextLength" Value="1073741823" />
     182                    </Window>
     183                    <Window Type="MenuWidgets/Checkbox" Name="orxonox/Settings/MeshLodCheckbox" >
     184                        <Property Name="Text" Value="Enable mesh LOD" />
     185                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     186                        <Property Name="UnifiedAreaRect" Value="{{0.035,0},{0.44,0},{0.5,0},{0.51,0}}" />
     187                    </Window>
     188                    <Window Type="MenuWidgets/Checkbox" Name="orxonox/Settings/MotionBlurCheckbox" >
     189                        <Property Name="Text" Value="Enable motion blur" />
     190                        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     191                        <Property Name="UnifiedAreaRect" Value="{{0.035,0},{0.57,0},{0.5,0},{0.64,0}}" />
     192                    </Window>
    29193                </Window>
    30194            </Window>
    31             <Window Type="MenuWidgets/StaticText" Name="orxonox/Themes" >
    32                 <Property Name="Text" Value="Themes" />
    33                 <Property Name="InheritsAlpha" Value="False" />
    34                 <Property Name="HorzFormatting" Value="HorzCentred" />
    35                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    36                 <Property Name="VertFormatting" Value="TopAligned" />
    37                 <Property Name="UnifiedAreaRect" Value="{{0.525,0},{0.10,0},{0.95,0},{0.35,0}}" />
    38                 <Window Type="MenuWidgets/Listbox" Name="orxonox/ThemeDropBox" >
    39                     <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    40                     <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.3,0},{0.95,0},{0.95,0}" />
    41                     <Event Name="ItemSelectionChanged" Function="GraphicsMenu.ThemeDropBox_changed"/>
    42                 </Window>
    43             </Window>
    44             <Window Type="MenuWidgets/StaticText" Name="orxonox/Brightness" >
    45                 <Property Name="Text" Value="Brightness" />
    46                 <Property Name="InheritsAlpha" Value="False" />
    47                 <Property Name="HorzFormatting" Value="HorzCentred" />
    48                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    49                 <Property Name="VertFormatting" Value="TopAligned" />
    50                 <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.70,0},{0.475,0},{0.85,0}}" />
    51                 <Window Type="MenuWidgets/HorizontalScrollbar" Name="orxonox/BrightnessScrollbar" >
    52                     <Property Name="Disabled" Value="true" />
    53                     <Property Name="PageSize" Value="0" />
    54                     <Property Name="StepSize" Value="0.1" />
    55                     <Property Name="OverlapSize" Value="0" />
    56                     <Property Name="DocumentSize" Value="1" />
    57                     <Property Name="ScrollPosition" Value="0" />
    58                     <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    59                     <Property Name="UnifiedAreaRect" Value="{{0.05,0},{0.6,0},{0.95,0},{0.8,0}}" />
    60                     <Event Name="ThumbTrackStarted" Function="GraphicsMenu.GraphicsBrightnessScrollbar_started" />
    61                     <Event Name="ThumbTrackEnded" Function="GraphicsMenu.GraphicsBrightnessScrollbar_ended" />
    62                     <Event Name="ScrollPosChanged" Function="GraphicsMenu.GraphicsBrightnessScrollbar_changed" />
    63                 </Window>
    64             </Window>
    65             <Window Type="MenuWidgets/Checkbox" Name="orxonox/FullscreenCheckbox" >
    66                 <Property Name="Text" Value="Fullscreen" />
    67                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    68                 <Property Name="UnifiedAreaRect" Value="{{0.65,0},{0.35,0},{0.85,0},{0.425,0}}" />
    69                 <Event Name="CheckStateChanged" Function="GraphicsMenu.GraphicsFullscreenCheckbox_clicked"/>
    70             </Window>
    71             <Window Type="MenuWidgets/StaticText" Name="orxonox/GraphicsInfo" >
    72                 <Property Name="Text" >
    73 Changes in graphics
    74 settings require
    75 a game restart.</Property>
    76                 <Property Name="TextColours" Value="FFFFFFFF" />
    77                 <Property Name="InheritsAlpha" Value="False" />
    78                 <Property Name="HorzFormatting" Value="HorzCentred" />
    79                 <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    80                 <Property Name="VertFormatting" Value="TopAligned" />
    81                 <Property Name="UnifiedAreaRect" Value="{{0.525,0},{0.425,0},{0.95,0},{0.85,0}}" />
    82             </Window>
    83195        </Window>
    84         <Window Type="MenuWidgets/Button" Name="orxonox/GraphicsBackButton" >
    85             <Property Name="Text" Value="Back" />
     196        <Window Type="MenuWidgets/Button" Name="orxonox/GraphicsOkButton" >
     197            <Property Name="Text" Value="OK" />
    86198            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    87             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
    88             <Event Name="Clicked" Function="GraphicsMenu.GraphicsBackButton_clicked"/>
     199            <Property Name="UnifiedAreaRect" Value="{{0.2875,0},{0.6625,0},{0.4875,0},{0.7125,0}}" />
     200            <Event Name="Clicked" Function="GraphicsMenu.callback_Ok_Clicked" />
     201        </Window>
     202        <Window Type="MenuWidgets/Button" Name="orxonox/GraphicsCancelButton" >
     203            <Property Name="Text" Value="Cancel" />
     204            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     205            <Property Name="UnifiedAreaRect" Value="{{0.5125,0},{0.6625,0},{0.7125,0},{0.7125,0}}" />
     206            <Event Name="Clicked" Function="GraphicsMenu.callback_Cancel_Clicked" />
    89207        </Window>
    90208    </Window>
  • code/branches/tutorial/data/gui/scripts/GUISheet.lua

    r7928 r8051  
    2828end
    2929
     30-- Override this function if you want to react on keystrokes
     31function P:onKeyPressed(mode)
     32end
     33
     34-- Override this function if you want to update the gui after the window was resized
     35function P:onWindowResized()
     36end
     37
    3038-- show function for the GUI
    3139function P:show()
     
    7785
    7886-- Handles key pressed while the gui sheed is displayed
    79 function P:keyPressed()
     87function P:keyPressed(mode)
    8088    if self.buttons then
    81         if code == "208" then     -- key down
     89        if mode == "down" then     -- key down
    8290            self:moveSelectionRow(1)
    83         elseif code == "200" then -- key up
     91        elseif mode == "up" then -- key up
    8492            self:moveSelectionRow(-1)
    85         elseif code == "205" then -- key right
     93        elseif mode == "right" then -- key right
    8694            self:moveSelectionColumn(1)
    87         elseif code == "203" then -- key left
     95        elseif mode == "left" then -- key left
    8896            self:moveSelectionColumn(-1)
    89         elseif code == "28"  then -- key enter
     97        elseif mode == "enter" then -- key enter or key numpad enter
    9098            self:pressSelectedButton()
    9199        end
    92100    end
    93101
    94     self.onKeyPressed()
    95 end
    96 
    97 -- Override this function if you want to ract on keystrokes
    98 function P:onKeyPressed()
     102    self:onKeyPressed(mode)
     103end
     104
     105function P:windowResized()
     106    self:onWindowResized()
    99107end
    100108
  • code/branches/tutorial/data/gui/scripts/GraphicsMenu.lua

    r7928 r8051  
    11-- GraphicsMenu.lua
    22
    3 local P = createMenuSheet("GraphicsMenu")
    4 
     3local P = createMenuSheet("GraphicsMenu", true, TriBool.True, TriBool.True)
     4
     5P.resolutionList = {"custom", "640 x 480", "720 x 480", "720 x 576", "800 x 600", "1024 x 600", "1024 x 768", "1152 x 864", "1280 x 720", "1280 x 800", "1280 x 960", "1280 x 1024", "1360 x 768", "1440 x 900", "1600 x 900", "1600 x 1200", "1680 x 1050"}
    56P.schemeList = {"TaharezGreen", "Orxonox"}
    6 
    7 function P.onLoad()
    8     block = true
    9     file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
    10     search_mode = 0
    11     f = io.open(file, "r")
    12     firstline = f:read("*line")
    13     rendersystem = string.sub(firstline, 15)
    14     for line in f:lines() do
    15         if search_mode == 0 then
    16             if string.find(line, rendersystem) ~= nil then
    17                 search_mode = 1
    18             end
     7P.fsaaList = {"0", "2", "4", "8", "8 [Quality]"}
     8P.particleLodList = {"None", "Low", "Normal", "High"}
     9
     10function P:onLoad()
     11    -------------------
     12    -- Button matrix --
     13    -------------------
     14
     15    P:setButton(1, 1, {
     16            ["button"] = winMgr:getWindow("orxonox/GraphicsOkButton"),
     17            ["callback"]  = P.callback_Ok_Clicked
     18    })
     19
     20    P:setButton(1, 2, {
     21            ["button"] = winMgr:getWindow("orxonox/GraphicsCancelButton"),
     22            ["callback"]  = P.callback_Cancel_Clicked
     23    })
     24
     25    -- place apply button at the bottom in the matrix, even though it's in fact at the top, to make the OK button highlighted by default
     26    P:setButton(2, 1, {
     27            ["button"] = winMgr:getWindow("orxonox/Display/Resolution/Apply"),
     28            ["callback"]  = P.callback_Apply_Clicked
     29    })
     30
     31    -----------------
     32    -- Combo boxes --
     33    -----------------
     34
     35    -- resolution combobox
     36    local resolutionCombobox = winMgr:getWindow("orxonox/Display/Resolution/Combobox")
     37    CEGUI.toCombobox(resolutionCombobox):setReadOnly(true)
     38
     39    for k,v in pairs(P.resolutionList) do
     40        local item = CEGUI.createListboxTextItem(v)
     41        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     42        resolutionCombobox:addItem(item)
     43    end
     44
     45    -- themes combobox
     46    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     47    CEGUI.toCombobox(themeCombobox):setReadOnly(true)
     48
     49    for k,v in pairs(P.schemeList) do
     50        local item = CEGUI.createListboxTextItem(v)
     51        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     52        themeCombobox:addItem(item)
     53    end
     54
     55    -- fsaa combobox
     56    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     57    CEGUI.toCombobox(fsaaCombobox):setReadOnly(true)
     58
     59    for k,v in pairs(P.fsaaList) do
     60        local item = CEGUI.createListboxTextItem(v)
     61        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     62        fsaaCombobox:addItem(item)
     63    end
     64
     65    -- particle lod combobox
     66    local particleLodCombobox = winMgr:getWindow("orxonox/Settings/ParticleLodCombobox")
     67    CEGUI.toCombobox(particleLodCombobox):setReadOnly(true)
     68
     69    for k,v in pairs(P.particleLodList) do
     70        local item = CEGUI.createListboxTextItem(v)
     71        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     72        particleLodCombobox:addItem(item)
     73    end
     74end
     75
     76function P:onShow()
     77    -----------------
     78    -- Display tab --
     79    -----------------
     80
     81    -- fullscreen checkbox / resolution combobox / resolution editboxes
     82    self:onWindowResized()
     83
     84    -- apply button
     85    self.updateApplyButton()
     86
     87    -- aspect ratio editbox
     88    local aspectRatioEditbox = winMgr:getWindow("orxonox/Display/Resolution/AspectRatio")
     89    local currentAspectRatio = orxonox.CommandExecutor:query("getConfig Camera aspectRatio_")
     90    aspectRatioEditbox:setText(currentAspectRatio)
     91
     92    -- themes combobox
     93    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     94    local currentTheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
     95
     96    for i = 0, themeCombobox:getDropList():getItemCount() - 1 do
     97        local item = themeCombobox:getListboxItemFromIndex(i)
     98        themeCombobox:setItemSelectState(item, (item:getText() == currentTheme))
     99    end
     100
     101    -- vsync checkbox
     102    local vsyncCheckbox = winMgr:getWindow("orxonox/Display/More/VSync")
     103    local hasVSync = orxonox.GraphicsManager:getInstance():hasVSyncEnabled()
     104    CEGUI.toCheckbox(vsyncCheckbox):setSelected(hasVSync)
     105
     106    -- fsaa combobox
     107    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     108    local currentFSAAMode = orxonox.GraphicsManager:getInstance():getFSAAMode()
     109
     110    for i = 0, fsaaCombobox:getDropList():getItemCount() - 1 do
     111        local item = fsaaCombobox:getListboxItemFromIndex(i)
     112        fsaaCombobox:setItemSelectState(item, (item:getText() == currentFSAAMode))
     113    end
     114
     115    -- notice
     116    self:updateRedLabel()
     117
     118    ------------------
     119    -- Settings tab --
     120    ------------------
     121
     122    -- fov editbox
     123    local fovEditbox = winMgr:getWindow("orxonox/Settings/Fov")
     124    local currentFov = orxonox.CommandExecutor:query("getConfig Camera fov_")
     125    fovEditbox:setText(currentFov)
     126
     127    -- fps limit editbox
     128    local fpsEditbox = winMgr:getWindow("orxonox/Settings/FpsLimit")
     129    local currentFpsLimit = orxonox.CommandExecutor:query("getConfig GraphicsSettings fpsLimit")
     130    fpsEditbox:setText(currentFpsLimit)
     131
     132    -- particle lod combobox
     133    local particleLodCombobox = winMgr:getWindow("orxonox/Settings/ParticleLodCombobox")
     134    local currentParticleLod = orxonox.CommandExecutor:query("getConfig GraphicsSettings particlesDetailLevel")
     135
     136    if currentParticleLod == "" then
     137        particleLodCombobox:disable()
     138    else
     139        particleLodCombobox:enable()
     140
     141        for i = 0, particleLodCombobox:getDropList():getItemCount() - 1 do
     142            local item = particleLodCombobox:getListboxItemFromIndex(i)
     143            particleLodCombobox:setItemSelectState(item, (tostring(i) == currentParticleLod))
    19144        end
    20         if search_mode == 1 then
    21             if string.sub(line, 1, 11) == "Full Screen" then
    22                 if string.sub(line, 13) == "Yes" then
    23                     fullscreen = true
    24                 else
    25                     fullscreen = false
    26                 end
    27             end
    28             if string.sub(line, 1, 10) == "Video Mode" then
    29                 if string.match(line, "@") == "@" then
    30                     resolution = string.sub(line, 12, string.find(line, "@")-2)
    31                 else
    32                     resolution = string.sub(line, 12)
    33                 end
    34                 break
    35             end
     145    end
     146
     147    -- mesh lod checkbox
     148    local meshLodCheckbox = winMgr:getWindow("orxonox/Settings/MeshLodCheckbox")
     149    local hasMeshLod = orxonox.CommandExecutor:query("getConfig GraphicsSettings enableMeshLoD")
     150    if hasMeshLod == "true" then
     151        hasMeshLod = true
     152    elseif hasMeshLod == "false" then
     153        hasMeshLod = false
     154    end
     155    CEGUI.toCheckbox(meshLodCheckbox):setSelected(hasMeshLod)
     156
     157    -- motion blur checkbox
     158    local motionBlurCheckbox = winMgr:getWindow("orxonox/Settings/MotionBlurCheckbox")
     159    local hasMotionBlur = orxonox.CommandExecutor:query("getConfig GraphicsSettings enableMotionBlur")
     160    if hasMotionBlur == "true" then
     161        hasMotionBlur = true
     162    elseif hasMotionBlur == "false" then
     163        hasMotionBlur = false
     164    end
     165    CEGUI.toCheckbox(motionBlurCheckbox):setSelected(hasMotionBlur)
     166end
     167
     168function P:onWindowResized()
     169    -- fullscreen checkbox
     170    local fullscreenCheckbox = winMgr:getWindow("orxonox/Display/Resolution/Fullscreen")
     171    local isFullscreen = orxonox.GraphicsManager:getInstance():isFullScreen()
     172    CEGUI.toCheckbox(fullscreenCheckbox):setSelected(isFullscreen)
     173
     174    -- resolution combobox
     175    local resolutionCombobox = winMgr:getWindow("orxonox/Display/Resolution/Combobox")
     176
     177    local currentWidth = orxonox.GraphicsManager:getInstance():getWindowWidth()
     178    local currentHeight = orxonox.GraphicsManager:getInstance():getWindowHeight()
     179
     180    if P.forceResolutionEditboxes then
     181        currentWidth = P.newWidth
     182        currentHeight = P.newHeight
     183        P.forceResolutionEditboxes = false
     184    end
     185
     186    local currentResolution = currentWidth .. " x " .. currentHeight
     187
     188    for i = 0, resolutionCombobox:getDropList():getItemCount() - 1 do
     189        local item = resolutionCombobox:getListboxItemFromIndex(i)
     190        resolutionCombobox:setItemSelectState(item, item:getText() == currentResolution)
     191    end
     192
     193    -- resolution editboxes
     194    self.updateResolutionEditboxes()
     195end
     196
     197----------------------
     198-- Helper functions --
     199----------------------
     200
     201-- updates the text of the resolution checkboxes and checks if they should be enabled (only if the "custom" resolution was selected)
     202function P.updateResolutionEditboxes()
     203    -- resolution combobox
     204    local resolutionCombobox = winMgr:getWindow("orxonox/Display/Resolution/Combobox")
     205
     206    local currentWidth = orxonox.GraphicsManager:getInstance():getWindowWidth()
     207    local currentHeight = orxonox.GraphicsManager:getInstance():getWindowHeight()
     208
     209    -- resolution editboxes
     210    local widthEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxWidth")
     211    local heightEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxHeight")
     212    widthEditbox:disable()
     213    heightEditbox:disable()
     214
     215    -- selected combobox item
     216    local item = resolutionCombobox:getSelectedItem()
     217    if item then
     218        local itemText = item:getText()
     219        if itemText ~= "custom" then
     220            currentWidth = string.sub(itemText, 1, string.find(itemText, "x") - 2)
     221            currentHeight = string.sub(itemText, string.find(itemText, "x") + 2)
     222        else
     223            widthEditbox:enable()
     224            heightEditbox:enable()
    36225        end
    37226    end
    38     f:close()
    39     local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
    40     fullscreenwindow:setSelected(fullscreen)
    41     listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
    42     local resolutionList = {}
    43     table.insert(resolutionList, "640 x 480")
    44     table.insert(resolutionList, "720 x 480")
    45     table.insert(resolutionList, "720 x 576")
    46     table.insert(resolutionList, "800 x 480")
    47     table.insert(resolutionList, "800 x 600")
    48     table.insert(resolutionList, "1024 x 480")
    49     table.insert(resolutionList, "1024 x 600")
    50     table.insert(resolutionList, "1024 x 768")
    51     table.insert(resolutionList, "1152 x 864")
    52     table.insert(resolutionList, "1280 x 720")
    53     table.insert(resolutionList, "1280 x 768")
    54     table.insert(resolutionList, "1440 x 900")
    55     for k,v in pairs(resolutionList) do
    56         item = CEGUI.createListboxTextItem(v)
    57         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    58         CEGUI.toListbox(listboxwindow):addItem(item)
    59     end
    60     if resolution == "640 x 480" then
    61         listboxwindow:setItemSelectState(0,true)
    62     elseif resolution == "720 x 480" then
    63         listboxwindow:setItemSelectState(1,true)
    64     elseif resolution == "720 x 576" then
    65         listboxwindow:setItemSelectState(2,true)
    66     elseif resolution == "800 x 480" then
    67         listboxwindow:setItemSelectState(3,true)
    68     elseif resolution == "800 x 600" then
    69         listboxwindow:setItemSelectState(4,true)
    70     elseif resolution == "1024 x 480" then
    71         listboxwindow:setItemSelectState(5,true)
    72     elseif resolution == "1024 x 600" then
    73         listboxwindow:setItemSelectState(6,true)
    74     elseif resolution == "1024 x 768" then
    75         listboxwindow:setItemSelectState(7,true)
    76     elseif resolution == "1152 x 864" then
    77         listboxwindow:setItemSelectState(8,true)
    78     elseif resolution == "1280 x 720" then
    79         listboxwindow:setItemSelectState(9,true)
    80     elseif resolution == "1280 x 768" then
    81         listboxwindow:setItemSelectState(10,true)
    82     elseif resolution == "1440 x 900" then
    83         listboxwindow:setItemSelectState(11,true)
    84     end
    85     scrollbar_active = false
    86     block = false
    87 
    88     P:setButton(1, 1, {
    89             ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"),
    90             ["callback"]  = P.GraphicsBackButton_clicked
    91     })
    92 
    93     local dropbox = winMgr:getWindow("orxonox/ThemeDropBox")
    94     local scheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
    95     for k,v in pairs(P.schemeList) do
    96         local item = CEGUI.createListboxTextItem(P.schemeList[k])
    97         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    98         CEGUI.toListbox(dropbox):addItem(item)
    99         if v == scheme then
    100             dropbox:setItemSelectState(item, true)
    101         end
    102     end
    103 
    104 end
    105 
    106 function P.ThemeDropBox_changed(e)
    107     local dropbox = winMgr:getWindow("orxonox/ThemeDropBox")
    108     local listbox = CEGUI.toListbox(dropbox)
    109     local choice = listbox:getFirstSelectedItem()
    110     local index = 0
    111     if choice ~= nil then
    112         index = listbox:getItemIndex(choice)
    113     end
    114     orxonox.CommandExecutor:execute("config GUIManager guiScheme_ " .. P.schemeList[index+1])
    115 end
    116 
    117 function P.GraphicsResolutionListbox_changed(e)
    118     if listboxwindow:isItemSelected(0) then
    119         resolution = "640 x 480"
    120     elseif listboxwindow:isItemSelected(1) then
    121         resolution = "720 x 480"
    122     elseif listboxwindow:isItemSelected(2) then
    123         resolution = "720 x 576"
    124     elseif listboxwindow:isItemSelected(3) then
    125         resolution = "800 x 480"
    126     elseif listboxwindow:isItemSelected(4) then
    127         resolution = "800 x 600"
    128     elseif listboxwindow:isItemSelected(5) then
    129         resolution = "1024 x 480"
    130     elseif listboxwindow:isItemSelected(6) then
    131         resolution = "1024 x 600"
    132     elseif listboxwindow:isItemSelected(7) then
    133         resolution = "1024 x 768"
    134     elseif listboxwindow:isItemSelected(8) then
    135         resolution = "1152 x 864"
    136     elseif listboxwindow:isItemSelected(9) then
    137         resolution = "1280 x 720"
    138     elseif listboxwindow:isItemSelected(10) then
    139         resolution = "1280 x 768"
    140     elseif listboxwindow:isItemSelected(11) then
    141         resolution = "1440 x 900"
    142     end
    143     search_mode = 0
    144     f = io.open(file, "r")
    145     firstline = f:read("*line")
    146     text = firstline .. "\n"
    147     rendersystem = string.sub(firstline, 15)
    148     for line in f:lines() do
    149         if search_mode == 0 then
    150             if string.find(line, rendersystem) ~= nil then
    151                 search_mode = 1
    152             end
    153         end
    154         if search_mode == 1 then
    155             if string.sub(line, 1, 10) == "Video Mode" then
    156                 if string.match(line, "@") == "@" then
    157                     line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
    158                 else
    159                     line = "Video Mode=" .. resolution
    160                 end
    161                 search_mode = 2
    162             end
    163         end
    164         text = text .. line .. "\n"
    165     end
    166     f:close()
    167     f = io.open(file, "w")
    168     f:write(text)
    169     f:close()
    170 end
    171 
    172 function P.GraphicsBrightnessScrollbar_changed(e)
    173     if scrollbar_active == false then
    174         -- brightness
    175         logMessage(0, "event: brightness")
    176     end
    177 end
    178 
    179 function P.GraphicsBrightnessScrollbar_started(e)
    180     scrollbar_active = true
    181 end
    182 
    183 function P.GraphicsBrightnessScrollbar_ended(e)
    184     -- brightness
    185     logMessage(0, "event: brightness")
    186     scrollbar_active = false
    187 end
    188 
    189 function P.GraphicsFullscreenCheckbox_clicked(e)
    190     if block == false then
    191         search_mode = 0
    192         f = io.open(file, "r")
    193         firstline = f:read("*line")
    194         text = firstline .. "\n"
    195         rendersystem = string.sub(firstline, 15)
    196         for line in f:lines() do
    197             if search_mode == 0 then
    198                 if string.find(line, rendersystem) ~= nil then
    199                     search_mode = 1
    200                 end
    201             end
    202             if search_mode == 1 then
    203                 if string.sub(line, 1, 11) == "Full Screen" then
    204                     if fullscreen == true then
    205                         line = "Full Screen=No"
    206                         fullscreen = false
    207                     else
    208                         line = "Full Screen=Yes"
    209                         fullscreen = true
    210                     end
    211                     search_mode = 2
    212                 end
    213             end
    214             text = text .. line .. "\n"
    215         end
    216         f:close()
    217         f = io.open(file, "w")
    218         f:write(text)
    219         f:close()
    220     end
    221 end
    222 
    223 function P.GraphicsBackButton_clicked(e)
     227
     228    widthEditbox:setText(currentWidth)
     229    heightEditbox:setText(currentHeight)
     230end
     231
     232-- checks if the apply button should be enabled or disabled (only enabled if the current settings are different from the selected values)
     233function P.updateApplyButton()
     234    -- fullscreen checkbox
     235    local fullscreenCheckbox = winMgr:getWindow("orxonox/Display/Resolution/Fullscreen")
     236    local isFullscreen = orxonox.GraphicsManager:getInstance():isFullScreen()
     237    local fullscreenChanged = (isFullscreen ~= CEGUI.toCheckbox(fullscreenCheckbox):isSelected())
     238
     239    -- resolution editboxes
     240    local widthEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxWidth")
     241    local heightEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxHeight")
     242    local currentWidth = tostring(orxonox.GraphicsManager:getInstance():getWindowWidth())
     243    local currentHeight = tostring(orxonox.GraphicsManager:getInstance():getWindowHeight())
     244    local widthChanged = (currentWidth ~= widthEditbox:getText())
     245    local heightChanged = (currentHeight ~= heightEditbox:getText())
     246    local resolutionEditboxesEnabled = not widthEditbox:isDisabled()
     247
     248    -- apply button
     249    local applyButton = winMgr:getWindow("orxonox/Display/Resolution/Apply")
     250
     251    if fullscreenChanged or widthChanged or heightChanged or resolutionEditboxesEnabled then
     252        applyButton:enable()
     253    else
     254        applyButton:disable()
     255    end
     256end
     257
     258function P.updateRedLabel()
     259    -- theme
     260    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     261    local currentTheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
     262    local themeChanged = (currentTheme ~= themeCombobox:getText())
     263
     264    -- vsync
     265    local vsyncCheckbox = winMgr:getWindow("orxonox/Display/More/VSync")
     266    local hasVSync = orxonox.GraphicsManager:getInstance():hasVSyncEnabled()
     267    local vsyncChanged = (hasVSync ~= CEGUI.toCheckbox(vsyncCheckbox):isSelected())
     268
     269    -- fsaa
     270    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     271    local currentFSAAMode = orxonox.GraphicsManager:getInstance():getFSAAMode()
     272    local fsaaChanged = (currentFSAAMode ~= fsaaCombobox:getText())
     273
     274    local needRestart = themeChanged or vsyncChanged or fsaaChanged
     275
     276    local notice = winMgr:getWindow("orxonox/Display/Notice")
     277    notice:setVisible(not needRestart)
     278    local noticeRed = winMgr:getWindow("orxonox/Display/NoticeRed")
     279    noticeRed:setVisible(needRestart)
     280end
     281
     282---------------------
     283-- Event callbacks --
     284---------------------
     285
     286-- resolution
     287
     288function P.callback_FullscreenCheckbox_CheckStateChanged(e)
     289    P.updateApplyButton()
     290end
     291
     292function P.callback_ResolutionCombobox_ListSelectionAccepted(e)
     293    P.updateResolutionEditboxes()
     294end
     295
     296function P.callback_ResolutionEditboxWidth_TextChanged(e)
     297    P.updateApplyButton()
     298end
     299
     300function P.callback_ResolutionEditboxHeight_TextChanged(e)
     301    P.updateApplyButton()
     302end
     303
     304-- theme
     305
     306function P.callback_ThemeCombobox_ListSelectionAccepted(e)
     307    P.updateRedLabel()
     308end
     309
     310-- vsync
     311
     312function P.callback_VSyncCheckbox_CheckStateChanged(e)
     313    P.updateRedLabel()
     314end
     315
     316-- fsaa
     317
     318function P.callback_FSAACombobox_ListSelectionAccepted(e)
     319    P.updateRedLabel()
     320end
     321
     322-- buttons
     323
     324function P.callback_Apply_Clicked(e)
     325    -- resolution
     326    local fullscreenCheckbox = winMgr:getWindow("orxonox/Display/Resolution/Fullscreen")
     327    local checkedFullscreen = tostring(CEGUI.toCheckbox(fullscreenCheckbox):isSelected())
     328
     329    local widthEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxWidth")
     330    local heightEditbox = winMgr:getWindow("orxonox/Display/Resolution/EditboxHeight")
     331
     332    P.newWidth = widthEditbox:getText()
     333    P.newHeight = heightEditbox:getText()
     334    P.forceResolutionEditboxes = true
     335
     336    -- start revert timer
     337    P.oldWidth = orxonox.GraphicsManager:getInstance():getWindowWidth()
     338    P.oldHeight = orxonox.GraphicsManager:getInstance():getWindowHeight()
     339    P.oldFullscreen = orxonox.GraphicsManager:getInstance():isFullScreen()
     340
     341    P.revertTimerHandle = orxonox.CommandExecutor:query("delayreal 10 {hideGUI DecisionPopup; GraphicsManager setScreenResolution " .. P.oldWidth .. " " .. P.oldHeight .. " " .. tostring(P.oldFullscreen) .. "; config Core lastLevelTimestamp_ [expr [getConfig Core ogreConfigTimestamp_] + 1]}")
     342
     343    -- change settings
     344    orxonox.CommandExecutor:execute("GraphicsManager setScreenResolution " .. P.newWidth .. " " .. P.newHeight .. " " .. checkedFullscreen)
     345
     346    P.updateApplyButton()
     347
     348    -- prompt for confirmation
     349    openDecisionPopup("Do you want to keep these settings? (Settings will be reverted in 10 seconds if not accepted)", GraphicsMenu.callback_ApplyDecisionPopup)
     350    if checkedFullscreen then
     351        showCursor()
     352    end
     353end
     354
     355function P.callback_ApplyDecisionPopup(pressedOK)
     356    orxonox.CommandExecutor:execute("killdelay " .. P.revertTimerHandle)
     357
     358    if not pressedOK then
     359        orxonox.CommandExecutor:execute("GraphicsManager setScreenResolution " .. P.oldWidth .. " " .. P.oldHeight .. " " .. tostring(P.oldFullscreen))
     360        P:onShow()
     361    end
     362
     363    -- update timestamp to avoid showing the ogre config dialog again after the user accepted or reverted the resolution
     364    orxonox.CommandExecutor:execute("config Core lastLevelTimestamp_ [expr [getConfig Core ogreConfigTimestamp_] + 1]")
     365end
     366
     367function P.callback_Ok_Clicked(e)
     368    -- aspect ratio
     369    local aspectRatioEditbox = winMgr:getWindow("orxonox/Display/Resolution/AspectRatio")
     370    orxonox.CommandExecutor:execute("config Camera aspectRatio_ " .. aspectRatioEditbox:getText())
     371
     372    -- theme
     373    local themeCombobox = winMgr:getWindow("orxonox/Display/Theme/Combobox")
     374    orxonox.CommandExecutor:execute("config GUIManager guiScheme_ " .. themeCombobox:getText())
     375
     376    -- vsync
     377    local vsyncCheckbox = winMgr:getWindow("orxonox/Display/More/VSync")
     378    local hasVSync = orxonox.GraphicsManager:getInstance():hasVSyncEnabled()
     379    if hasVSync ~= CEGUI.toCheckbox(vsyncCheckbox):isSelected() then
     380        orxonox.CommandExecutor:execute("GraphicsManager setVSync " .. tostring(CEGUI.toCheckbox(vsyncCheckbox):isSelected()))
     381    end
     382
     383    -- fsaa
     384    local fsaaCombobox = winMgr:getWindow("orxonox/Display/More/FSAA")
     385    local currentFSAAMode = orxonox.GraphicsManager:getInstance():getFSAAMode()
     386    if currentFSAAMode ~= fsaaCombobox:getText() then
     387        orxonox.CommandExecutor:execute("GraphicsManager setFSAA {" .. fsaaCombobox:getText() .. "}") -- enclose argument in { ... } because it can contain [brackets] (conflicts with tcl)
     388    end
     389
     390    -- fov
     391    local fovEditbox = winMgr:getWindow("orxonox/Settings/Fov")
     392    orxonox.CommandExecutor:execute("config Camera fov_ " .. fovEditbox:getText())
     393
     394    -- fps limit
     395    local fpsEditbox = winMgr:getWindow("orxonox/Settings/FpsLimit")
     396    orxonox.CommandExecutor:execute("config GraphicsSettings fpsLimit " .. fpsEditbox:getText())
     397
     398    -- particle lod
     399    local particleLodCombobox = winMgr:getWindow("orxonox/Settings/ParticleLodCombobox")
     400    local item = particleLodCombobox:getSelectedItem()
     401    if item then
     402        orxonox.CommandExecutor:execute("config GraphicsSettings particlesDetailLevel " .. particleLodCombobox:getItemIndex(item))
     403    end
     404
     405    -- mesh lod
     406    local meshLodCheckbox = winMgr:getWindow("orxonox/Settings/MeshLodCheckbox")
     407    orxonox.CommandExecutor:execute("config GraphicsSettings enableMeshLoD " .. tostring(CEGUI.toCheckbox(meshLodCheckbox):isSelected()))
     408
     409    -- motion blur
     410    local motionBlurCheckbox = winMgr:getWindow("orxonox/Settings/MotionBlurCheckbox")
     411    orxonox.CommandExecutor:execute("config GraphicsSettings enableMotionBlur " .. tostring(CEGUI.toCheckbox(motionBlurCheckbox):isSelected()))
     412
    224413    hideMenuSheet(P.name)
    225414end
    226415
     416function P.callback_Cancel_Clicked(e)
     417    hideMenuSheet(P.name)
     418end
     419
    227420return P
    228421
  • code/branches/tutorial/data/gui/scripts/HostMenu.lua

    r7928 r8051  
    2828
    2929function P.onShow()
     30    if P.showAll ~= orxonox.GUIManager:inDevMode() then
     31        local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
     32        local button = tolua.cast(window,"CEGUI::Checkbox")
     33        P.showAll = not P.showAll
     34        button:setSelected(P.showAll)
     35    end
     36
    3037    if P.multiplayerMode == "startServer" then
    3138        local window = winMgr:getWindow("orxonox/HostMenuHostButton")
  • code/branches/tutorial/data/gui/scripts/KeyBindMenu.lua

    r7928 r8051  
    2626    table.insert(commandList, "NewHumanController changeMode")
    2727    table.insert(commandList, "switchCamera")
    28     table.insert(commandList, "openConsole")
     28    table.insert(commandList, "InGameConsole openConsole")
    2929    table.insert(commandList, "OverlayGroup toggleVisibility Debug")
    3030    table.insert(commandList, "OverlayGroup toggleVisibility Stats")
  • code/branches/tutorial/data/gui/scripts/MenuSheet.lua

    r7689 r8051  
    1616    newSheet.bHidePrevious  = handleDefArg(_bHidePrevious,  true)
    1717    newSheet.tShowCursor    = handleDefArg(_tShowCusor,     TriBool.True)
    18     newSheet.tUseKeyboard   = handleDefArg(_tUseKeyboard,   TriBool.True)
     18    newSheet.tUseKeyboard   = handleDefArg(_tUseKeyboard,   TriBool.Dontcare)
    1919    newSheet.bBlockJoyStick = handleDefArg(_bBlockJoyStick, false)
    2020
  • code/branches/tutorial/data/gui/scripts/MiscConfigMenu.lua

    r7928 r8051  
    3535    table.insert(P.commandList, "HumanPlayer nick_")
    3636    table.insert(P.commandList, "ChatOverlay displayTime_")
     37    table.insert(P.commandList, "Core bDevMode_")
    3738
    3839    P.nameList = {}
     
    5455    table.insert(P.nameList, "Playername")
    5556    table.insert(P.nameList, "Chat: display time")
     57    table.insert(P.nameList, "Developer's Mode")
    5658
    5759    P.linesList = {}
  • code/branches/tutorial/data/gui/scripts/SheetManager.lua

    r8015 r8051  
    55local activeMenuSheets = {size = 0, topSheetTuple = nil}
    66local menuSheetsRoot = guiMgr:getMenuRootWindow()
    7 local bInGameConsoleClosed = false
    87local mainMenuLoaded = false
    9 orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
    10 
    11 -----------------------
    12 --- Local functions ---
    13 -----------------------
    14 
    15 local function hideCursor()
    16     if cursor:isVisible() then
    17         cursor:hide()
    18     end
    19 end
    20 
    21 local function showCursor()
    22     if not cursor:isVisible() and inputMgr:isMouseExclusive() then
    23         cursor:show()
    24     end
    25 end
    26 
     8--orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "KeyDown", "keyPressed")
     9orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized")
    2710
    2811------------------------
    2912--- Global functions ---
    3013------------------------
     14
     15function hideCursor()
     16    if cursor:isVisible() then
     17        cursor:hide()
     18    end
     19end
     20
     21function showCursor()
     22    if not cursor:isVisible() and inputMgr:isMouseExclusive() then
     23        cursor:show()
     24    end
     25end
    3126
    3227-- Loads the GUI with the specified name
     
    9388        ["sheet"]          = menuSheet,
    9489        ["bHidePrevious"]  = bHidePrevious,
    95         ["bNoInput"]       = bNoInput
     90        ["bNoInput"]       = bNoInput,
     91        ["name"]           = name
    9692    }
    9793    table.insert(activeMenuSheets, sheetTuple) -- indexed array access
     
    135131    if previous and previous.pressedEnter and menuSheet:hasSelection() == false then
    136132        menuSheet:setSelectionNear(1, 1)
     133    end
     134
     135    if activeMenuSheets.size > 0 then
     136        guiMgr:guisActiveChanged(true)
    137137    end
    138138
     
    207207    end
    208208
     209    if activeMenuSheets.size == 0 then
     210        guiMgr:guisActiveChanged(false)
     211    end
     212
    209213    sheetTuple.sheet:quit()
    210214end
     
    220224    -- HUGE, very HUGE hacks!
    221225
    222     -- If the InGameConsole is active, ignore the ESC command.
    223     if bInGameConsoleClosed == true then
    224         bInGameConsoleClosed = false
    225         return
    226     end
    227 
    228     -- Count the number of sheets that don't need input till the first that does.
     226    -- Count the number of sheets that don't need input until the first that does.
    229227    local counter = noInputSheetIndex()
    230228
     
    240238end
    241239
    242 function keyPressed(e)
    243     local we = tolua.cast(e, "CEGUI::KeyEventArgs")
     240-- Function to navigate the GUI, is called by the GUIManager, whenever a relevant key is pressed.
     241-- The mode specifies the action to be taken.
     242function navigateGUI(mode)
    244243    local sheet = activeMenuSheets[activeMenuSheets.size]
    245     code = tostring(we.scancode)
    246     -- Some preprocessing
    247     if not mainMenuLoaded and not sheet.bNoInput then
    248         if code == "1" then
    249             keyESC()
    250         elseif code == "0"then
    251             orxonox.CommandExecutor:execute("openConsole")
    252         end
    253     end
    254     sheet.sheet:keyPressed()
     244    sheet.sheet:keyPressed(mode)
     245end
     246
     247function windowResized(e)
     248    for name, sheet in pairs(loadedSheets) do
     249        if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then
     250            inputMgr:setMouseExclusive(sheet.inputState, TriBool.True)
     251        else
     252            inputMgr:setMouseExclusive(sheet.inputState, TriBool.False)
     253        end
     254    end
     255    local sheetTuple = activeMenuSheets[activeMenuSheets.size]
     256    if sheetTuple then
     257        if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then
     258            showCursor()
     259        else
     260            hideCursor()
     261        end
     262        sheetTuple.sheet:windowResized()
     263    end
    255264end
    256265
     
    279288end
    280289
    281 function inGameConsoleClosed()
    282     bInGameConsoleClosed = not bInGameConsoleClosed;
     290function getGUIFirstActive(name, bHidePrevious, bNoInput)
     291    local sheet = activeMenuSheets.topSheetTuple
     292    -- If the topmost gui sheet has the input name
     293    if sheet ~= nil and sheet.name == name then
     294        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false);
     295    else
     296        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true);
     297    end
    283298end
    284299
  • code/branches/tutorial/data/gui/scripts/SingleplayerMenu.lua

    r7928 r8051  
    2525end
    2626
     27function P.onShow()
     28    if P.showAll ~= orxonox.GUIManager:inDevMode() then
     29        local window = winMgr:getWindow("orxonox/SingleplayerShowAllCheckbox")
     30        local button = tolua.cast(window,"CEGUI::Checkbox")
     31        P.showAll = not P.showAll
     32        button:setSelected(P.showAll)
     33        P.createLevelList()
     34    end
     35end
     36
    2737function P.createLevelList()
    2838    P.levelList = {}
     
    4454        index = index + 1
    4555    end
    46     --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
    47     --table.sort(levelList)
    4856    for k,v in pairs(P.levelList) do
    4957        local item = CEGUI.createListboxTextItem(v:getName())
  • code/branches/tutorial/data/levels/presentation09.oxw

    r7962 r8051  
    11<LevelInfo
    2  name = "Presentation X"
    3  description = "1st Presentation level for Orxonox Convention X"
     2 name = "Presentation X 3rd"
     3 description = "3rd Presentation level for Orxonox Convention X"
    44 tags = "presentation"
    55/>
  • code/branches/tutorial/data/levels/presentationFS102.oxw

    r7679 r8051  
    11<LevelInfo
    2  name = "Presentation XI FPS"
     2 name = "Presentation XI FPS 1st"
    33 description = "2nd Presentation level for Orxonox Convention XI, FPS"
    44 tags = "presentation"
  • code/branches/tutorial/data/levels/presentationFS10Ed.oxw

    r7679 r8051  
    11<LevelInfo
    2  name = "Presentation XI FPS"
     2 name = "Presentation XI FPS 2nd"
    33 description = "3rd Presentation level for Orxonox Convention XI, FPS"
    44 tags = "presentation"
  • code/branches/tutorial/data/levels/presentationHS09.oxw

    r7962 r8051  
    11<LevelInfo
    2  name = "Presentation X"
     2 name = "Presentation X 1st"
    33 description = "1st Presentation level for Orxonox Convention X"
    44 tags = "presentation"
  • code/branches/tutorial/data/levels/presentationHS09b.oxw

    r7962 r8051  
    11<LevelInfo
    2  name = "Presentation X"
     2 name = "Presentation X 2nd"
    33 description = "2nd Presentation level for Orxonox Convention X"
    44 tags = "presentation"
  • code/branches/tutorial/data/overlays/debug.oxo

    r7935 r8051  
    6868    <PauseNotice
    6969     name     = "pausenotice"
    70      position = "0.5, 0.3"
     70     position = "0.5, 0.1"
    7171     font     = "VeraMono"
    7272     textsize = 0.03
  • code/branches/tutorial/src/libraries/core/CMakeLists.txt

    r7966 r8051  
    8080    Game.h
    8181    GameMode.h
     82    GraphicsManager.h
    8283    GUIManager.h
    8384    Loader.h
  • code/branches/tutorial/src/libraries/core/Core.cc

    r7872 r8051  
    208208#ifdef ORXONOX_RELEASE
    209209        const unsigned int defaultLevelLogFile = 3;
     210        SetConfigValue(bDevMode_, false)
     211            .description("Developer mode. If not set, hides some things from the user to not confuse him.");
    210212#else
    211213        const unsigned int defaultLevelLogFile = 4;
     214        SetConfigValue(bDevMode_, true)
     215            .description("Developer mode. If not set, hides some things from the user to not confuse him.");
    212216#endif
    213217        SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
  • code/branches/tutorial/src/libraries/core/Core.h

    r7870 r8051  
    9191                { return this->ogreConfigTimestamp_; }
    9292
     93            inline bool inDevMode(void) const
     94                { return this->bDevMode_; }
     95
    9396        private:
    9497            Core(const Core&); //!< Don't use (undefined symbol)
     
    130133            long long                     lastLevelTimestamp_;         ///< Timestamp when the last level was started
    131134            long long                     ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
     135            bool                          bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
    132136
    133137            static Core*                  singletonPtr_s;
  • code/branches/tutorial/src/libraries/core/GUIManager.cc

    r7994 r8051  
    103103    /*static*/ const std::string GUIManager::defaultScheme_ = "TaharezGreen";
    104104
     105    static const std::string __CC_navigateGUI_name = "navigateGUI";
     106
    105107    SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false);
    106108    SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
     109    SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
     110    SetConsoleCommand(__CC_navigateGUI_name, &GUIManager::navigateGUI).deactivate();
     111
     112    //! Strings that specify modes for the GUI navigation.
     113    /*static*/ const std::string GUIManager::NAVIGATE_UP = "up";
     114    /*static*/ const std::string GUIManager::NAVIGATE_DOWN = "down";
     115    /*static*/ const std::string GUIManager::NAVIGATE_LEFT = "left";
     116    /*static*/ const std::string GUIManager::NAVIGATE_RIGHT = "right";
     117    /*static*/ const std::string GUIManager::NAVIGATE_ENTER = "enter";
    107118
    108119    /**
     
    282293    {
    283294        GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")");
     295    }
     296
     297    /**
     298    @brief
     299        Toggles specified GUI.
     300        If the GUI with the input name is already shown and on the top, it is hidden, else it is shown.
     301    */
     302    /*static*/ void GUIManager::toggleGUI(const std::string& name, bool bHidePrevious, bool bNoInput)
     303    {
     304        GUIManager::getInstance().executeCode("getGUIFirstActive(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")");
     305    }
     306
     307    /**
     308    @brief
     309        Helper method to toggle a specified GUI.
     310        Is called by lua.
     311    */
     312    void GUIManager::toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show)
     313    {
     314        if(show)
     315            GUIManager::showGUI(name, bHidePrevious, bNoInput);
     316        else
     317            GUIManager::hideGUI(name);
    284318    }
    285319
     
    340374            this->rootWindow_->setProperty("Alpha", "1.0");
    341375        this->rootWindow_->setProperty("Image", image);
     376    }
     377
     378    /**
     379    @brief
     380        Method to navigate the GUI, by specifying the mode of navigation.
     381    @param mode
     382        The mode of navigation, at this point can be either 'up', 'down', 'left', 'right' or 'enter'.
     383    */
     384    /*static*/ void GUIManager::navigateGUI(const std::string& mode)
     385    {
     386        if(mode == NAVIGATE_UP)
     387            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_UP + "\")");
     388        else if(mode == NAVIGATE_DOWN)
     389            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_DOWN + "\")");
     390        else if(mode == NAVIGATE_LEFT)
     391            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_LEFT + "\")");
     392        else if(mode == NAVIGATE_RIGHT)
     393            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_RIGHT + "\")");
     394        else if(mode == NAVIGATE_ENTER)
     395            GUIManager::getInstance().executeCode("navigateGUI(\"" + NAVIGATE_ENTER + "\")");
     396    }
     397
     398    /**
     399    @brief
     400        Is called by lua to change whether there are any GUIs active at the moment.
     401    @param active
     402        Whether GUIs are active.
     403    */
     404    void GUIManager::guisActiveChanged(bool active)
     405    {
     406        if(this->GUIsActive_ == active)
     407            return;
     408        this->GUIsActive_ = active;
     409        if(this->GUIsActive_)
     410            ModifyConsoleCommand(__CC_navigateGUI_name).activate();
     411        else
     412            ModifyConsoleCommand(__CC_navigateGUI_name).deactivate();
    342413    }
    343414
  • code/branches/tutorial/src/libraries/core/GUIManager.h

    r7874 r8051  
    4949#include "util/Singleton.h"
    5050#include "input/InputHandler.h"
     51#include "Core.h"
    5152#include "OrxonoxClass.h"
    5253#include "WindowEventListener.h"
     
    8889        void showGUIExtra(const std::string& name, const std::string& ptr, bool bHidePrevious = false, bool bNoInput = false);
    8990        static void hideGUI(const std::string& name);
     91        static void toggleGUI(const std::string& name, bool bHidePrevious = false, bool bNoInput = false);
     92        void toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show); // tolua_export
    9093        void keyESC();
    9194        void setBackgroundImage(const std::string& imageSet, const std::string imageName); // tolua_export
    9295        void setBackgroundImage(const std::string& image);
     96
     97        static void navigateGUI(const std::string& mode);
     98        void guisActiveChanged(bool active); // tolua_export
     99
     100        /**
     101        @brief Helper method to get the developer's mode without having to export Core.h.
     102        @see Core::inDevMode
     103        */
     104        static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export
    93105
    94106        //! Creates a new InputState to be used with a GUI Sheet
     
    122134        template <typename FunctionType>
    123135        bool protectedCall(FunctionType function);
     136
     137        static const std::string NAVIGATE_UP;
     138        static const std::string NAVIGATE_DOWN;
     139        static const std::string NAVIGATE_LEFT;
     140        static const std::string NAVIGATE_RIGHT;
     141        static const std::string NAVIGATE_ENTER;
     142
     143        bool GUIsActive_; //!< Whether there are any GUIs active at a given moment.
    124144
    125145        // keyHandler functions
  • code/branches/tutorial/src/libraries/core/Game.cc

    r7993 r8051  
    6161    static void printFPS()
    6262        { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
    63     SetConsoleCommand("printFPS", &printFPS);
     63    SetConsoleCommand("Stats", "printFPS", &printFPS);
    6464    static void printTickTime()
    6565        { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
    66     SetConsoleCommand("printTickTime", &printTickTime);
     66    SetConsoleCommand("Stats", "printTickTime", &printTickTime);
    6767
    6868    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
  • code/branches/tutorial/src/libraries/core/GraphicsManager.cc

    r8008 r8051  
    480480    }
    481481
     482    unsigned int GraphicsManager::getWindowWidth() const
     483    {
     484        return this->renderWindow_->getWidth();
     485    }
     486
     487    unsigned int GraphicsManager::getWindowHeight() const
     488    {
     489        return this->renderWindow_->getHeight();
     490    }
     491
    482492    bool GraphicsManager::hasVSyncEnabled() const
    483493    {
    484494        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
    485         if (options.find("VSync") != options.end())
    486             return (options["VSync"].currentValue == "Yes");
     495        Ogre::ConfigOptionMap::iterator it = options.find("VSync");
     496        if (it != options.end())
     497            return (it->second.currentValue == "Yes");
    487498        else
    488499            return false;
    489500    }
    490501
     502    std::string GraphicsManager::getFSAAMode() const
     503    {
     504        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
     505        Ogre::ConfigOptionMap::iterator it = options.find("FSAA");
     506        if (it != options.end())
     507            return it->second.currentValue;
     508        else
     509            return "";
     510    }
     511
    491512    std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen)
    492513    {
    493         this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width) + " x " + multi_cast<std::string>(height) + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour");
     514        // workaround to detect if the colour depth should be written to the config file
     515        bool bWriteColourDepth = false;
     516        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
     517        Ogre::ConfigOptionMap::iterator it = options.find("Video Mode");
     518        if (it != options.end())
     519            bWriteColourDepth = (it->second.currentValue.find('@') != std::string::npos);
     520
     521        if (bWriteColourDepth)
     522        {
     523            this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width)
     524                                                                    + " x " + multi_cast<std::string>(height)
     525                                                                    + " @ " + multi_cast<std::string>(this->getRenderWindow()->getColourDepth()) + "-bit colour");
     526        }
     527        else
     528        {
     529            this->ogreRoot_->getRenderSystem()->setConfigOption("Video Mode", multi_cast<std::string>(width)
     530                                                                    + " x " + multi_cast<std::string>(height));
     531        }
     532
    494533        this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No");
    495534
  • code/branches/tutorial/src/libraries/core/GraphicsManager.h

    r7995 r8051  
    5454#include "OrxonoxClass.h"
    5555
     56// tolua_begin
    5657namespace orxonox
    5758{
     
    6061        Graphics engine manager class
    6162    */
    62     class _CoreExport GraphicsManager : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener
    63     {
     63    class _CoreExport GraphicsManager
     64// tolua_end
     65        : public Singleton<GraphicsManager>, public OrxonoxClass, public Ogre::LogListener
     66    { // tolua_export
    6467        friend class Singleton<GraphicsManager>;
    6568    public:
     
    7477        Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
    7578        size_t getRenderWindowHandle();
     79
     80// tolua_begin
     81        static GraphicsManager& getInstance() { return Singleton<GraphicsManager>::getInstance(); } // tolua_export
     82
    7683        bool isFullScreen() const;
     84        unsigned int getWindowWidth() const;
     85        unsigned int getWindowHeight() const;
     86
    7787        bool hasVSyncEnabled() const;
     88        std::string getFSAAMode() const;
     89// tolua_end
    7890
    7991        void upgradeToGraphics();
     
    127139
    128140        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
     141// tolua_begin
    129142    };
    130143}
     144// tolua_end
    131145
    132146#endif /* _GraphicsManager_H__ */
  • code/branches/tutorial/src/libraries/core/command/CommandEvaluation.h

    r7401 r8051  
    7070
    7171        @remarks execCommand_ and hintCommand_ can be different in this case: There are multiple
    72         commands avaliable, let's say "tcl", "tclexecute", and "tclquery". The user enters
    73         "tcl", which is already a valid command. Now execCommand_ points to the "tcl"-command,
    74         but hintCommand_ still points to the autocompletion command of CommandExecutor, because
    75         the auto-completion list must still return the three possible commands, "tcl tclexecute tclquery"
    76         because the user may want to execute "tclquery" and needs auto-completion.
     72        commands avaliable, let's say "tcl" and "TclThreadManager". The user enters "tcl", which
     73        is already a valid command. Now execCommand_ points to the "tcl"-command, but hintCommand_
     74        still points to the autocompletion command of CommandExecutor, because the auto-completion
     75        list must still return the two possible commands, "tcl TclThreadManager" because the user
     76        may want to write "TclThreadManager ..." and needs auto-completion.
    7777
    7878        @see See @ref CommandExecutorExample "this description" for an example.
  • code/branches/tutorial/src/libraries/core/command/ConsoleCommandCompilation.cc

    r7401 r8051  
    4646namespace orxonox
    4747{
    48     SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files());
     48//    SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files());  // disabled because we use the implementation in Tcl
    4949    SetConsoleCommand("echo", echo);
    50     SetConsoleCommand("puts", puts);
    51 
    52     SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files());
    53     SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files());
    54     SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files());
     50//    SetConsoleCommand("puts", puts);                                                    // disabled because we use the implementation in Tcl
     51
     52//    SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files());      // disabled because we use the implementation in Tcl
     53//    SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files());  // disabled because we use the implementation in Tcl
     54//    SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files());    // disabled because we use the implementation in Tcl
    5555
    5656    SetConsoleCommand("calculate", calculate);
  • code/branches/tutorial/src/libraries/core/command/Shell.cc

    r7401 r8051  
    4646{
    4747    SetConsoleCommand("log",     OutputHandler::log    );
    48     SetConsoleCommand("error",   OutputHandler::error  );
    49     SetConsoleCommand("warning", OutputHandler::warning);
    50     SetConsoleCommand("info",    OutputHandler::info   );
    51     SetConsoleCommand("debug",   OutputHandler::debug  );
     48    SetConsoleCommand("error",   OutputHandler::error  ).hide();
     49    SetConsoleCommand("warning", OutputHandler::warning).hide();
     50    SetConsoleCommand("info",    OutputHandler::info   ).hide();
     51    SetConsoleCommand("debug",   OutputHandler::debug  ).hide();
    5252
    5353    unsigned int Shell::cacheSize_s;
  • code/branches/tutorial/src/libraries/core/command/TclBind.cc

    r7401 r8051  
    4545{
    4646    SetConsoleCommand("tcl", &TclBind::tcl);
    47     SetConsoleCommand("bgerror", &TclBind::bgerror);
     47    SetConsoleCommand("bgerror", &TclBind::bgerror).hide();
    4848
    4949    TclBind* TclBind::singletonPtr_s = 0;
     
    9191
    9292            this->interpreter_->def("::orxonox::query", TclBind::tcl_query, Tcl::variadic());
     93            this->interpreter_->def("::orxonox::execute", TclBind::tcl_execute, Tcl::variadic());
    9394            this->interpreter_->def("::orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
    94             this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
    9595            this->interpreter_->def("::orxonox::crossexecute", TclThreadManager::tcl_crossexecute, Tcl::variadic());
    9696
    9797            try
    9898            {
    99                 this->interpreter_->eval("proc query        {args}    { ::orxonox::query $args }");
     99                this->interpreter_->def("query", TclBind::tcl_query, Tcl::variadic());
     100                this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
    100101                this->interpreter_->eval("proc crossquery   {id args} { ::orxonox::crossquery 0 $id $args }");
    101                 this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::crossquery 0 $id $args }");
     102                this->interpreter_->eval("proc crossexecute {id args} { ::orxonox::crossexecute 0 $id $args }");
    102103                this->interpreter_->eval("proc running      {}        { return 1 }");
    103104                this->interpreter_->eval("set id 0");
     
    154155    {
    155156        COUT(4) << "Tcl_query: " << args.get() << std::endl;
    156 
     157        return TclBind::tcl_helper(args, true);
     158    }
     159
     160    /**
     161        @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor.
     162    */
     163    void TclBind::tcl_execute(Tcl::object const &args)
     164    {
     165        COUT(4) << "Tcl_execute: " << args.get() << std::endl;
     166        TclBind::tcl_helper(args, false);
     167    }
     168
     169    /**
     170        @brief Helper function, used by tcl_query() and tcl_execute().
     171    */
     172    std::string TclBind::tcl_helper(Tcl::object const &args, bool bQuery)
     173    {
    157174        const std::string& command = stripEnclosingBraces(args.get());
    158175
    159176        int error;
     177        std::string result;
     178
    160179        CommandEvaluation evaluation = CommandExecutor::evaluate(command);
    161         const std::string& result = evaluation.query(&error);
     180
     181        if (bQuery)
     182            result = evaluation.query(&error).getString();
     183        else
     184            error = evaluation.execute();
     185
    162186        switch (error)
    163187        {
     
    175199
    176200    /**
    177         @brief Callback: Used to send an Orxonox-command from Tcl to the CommandExecutor.
    178     */
    179     void TclBind::tcl_execute(Tcl::object const &args)
    180     {
    181         COUT(4) << "Tcl_execute: " << args.get() << std::endl;
    182         const std::string& command = stripEnclosingBraces(args.get());
    183 
    184         if (CommandExecutor::execute(command, false))
    185         {
    186             COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
    187         }
    188     }
    189 
    190     /**
    191201        @brief Console command, executes Tcl code. Can be used to bind Tcl-commands to a key, because native
    192202        Tcl-commands can not be evaluated and are thus not supported by the key-binder.
     
    198208            try
    199209            {
    200                 const std::string& output = TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
    201                 if (!output.empty())
    202                 {
    203                     COUT(0) << "tcl> " << output << std::endl;
    204                 }
    205                 return output;
     210                return TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
    206211            }
    207212            catch (Tcl::tcl_error const &e)
    208             {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
     213            {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
    209214        }
    210215
  • code/branches/tutorial/src/libraries/core/command/TclBind.h

    r7401 r8051  
    126126            TclBind(const TclBind& other);      ///< Copy-constructor, not implemented
    127127
     128            static std::string tcl_helper(Tcl::object const &args, bool bQuery);
     129
    128130            Tcl::interpreter* interpreter_;     ///< The wrapped Tcl interpreter
    129131            std::string tclDataPath_;           ///< The path to the directory that contains the Orxonox-specific Tcl-files
  • code/branches/tutorial/src/libraries/core/command/TclThreadManager.cc

    r7401 r8051  
    5555    const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f;
    5656
    57     SetConsoleCommand("tclexecute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());
    58     SetConsoleCommand("tclquery",   &TclThreadManager::query  ).argumentCompleter(0, autocompletion::tclthreads());
    5957    SetConsoleCommand("TclThreadManager", "create",  &TclThreadManager::create);
    6058    SetConsoleCommand("TclThreadManager", "destroy", &TclThreadManager::destroy).argumentCompleter(0, autocompletion::tclthreads());
  • code/branches/tutorial/src/libraries/core/input/InputManager.cc

    r7874 r8051  
    641641        state->destroy();
    642642    }
     643
     644    bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value)
     645    {
     646        if (name == "empty")
     647        {
     648            COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl;
     649            return false;
     650        }
     651        std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
     652        if (it != statesByName_.end())
     653        {
     654            it->second->setMouseExclusive(value);
     655            return true;
     656        }
     657        return false;
     658    }
    643659}
  • code/branches/tutorial/src/libraries/core/input/InputManager.h

    r7874 r8051  
    163163        */
    164164        bool destroyState(const std::string& name); // tolua_export
     165        /**
     166        @brief
     167            Changes the mouse mode of an input state.
     168        @return
     169            True if the call was successful, fals if the name was not found
     170        */
     171        bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export
    165172
    166173        //-------------------------------
  • code/branches/tutorial/src/libraries/core/input/Keyboard.cc

    r6422 r8051  
    3636    {
    3737        // update modifiers
    38         if (arg.key == OIS::KC_RMENU    || arg.key == OIS::KC_LMENU)
    39             modifiers_ |= KeyboardModifier::Alt;   // alt key
    40         if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL)
    41             modifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
    42         if (arg.key == OIS::KC_RSHIFT   || arg.key == OIS::KC_LSHIFT)
    43             modifiers_ |= KeyboardModifier::Shift; // shift key
     38        switch (arg.key)
     39        {
     40            case OIS::KC_RMENU:
     41            case OIS::KC_LMENU:
     42                modifiers_ |= KeyboardModifier::Alt;   // alt key
     43                break;
     44            case OIS::KC_RCONTROL:
     45            case OIS::KC_LCONTROL:
     46                modifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
     47                break;
     48            case OIS::KC_RSHIFT:
     49            case OIS::KC_LSHIFT:
     50                modifiers_ |= KeyboardModifier::Shift; // shift key
     51                break;
     52            case OIS::KC_TAB:
     53                // Do not distribute the alt+tab event (messes with the operating system)
     54                if ((modifiers_ & KeyboardModifier::Alt) != 0)
     55                    return true;
     56            default:;
     57        }
    4458
    45         // Do not distribute the alt+tab event (messes with the operating system)
    46         if ((modifiers_ & KeyboardModifier::Alt) != 0 && arg.key == OIS::KC_TAB)
    47             return true;
    48 
    49         KeyEvent evt(arg);
     59        KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0);
    5060        super::buttonPressed(evt);
    5161        return true;
     
    5666    {
    5767        // update modifiers
    58         if (arg.key == OIS::KC_RMENU    || arg.key == OIS::KC_LMENU)
    59             modifiers_ &= ~KeyboardModifier::Alt;   // alt key
    60         if (arg.key == OIS::KC_RCONTROL || arg.key == OIS::KC_LCONTROL)
    61             modifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
    62         if (arg.key == OIS::KC_RSHIFT   || arg.key == OIS::KC_LSHIFT)
    63             modifiers_ &= ~KeyboardModifier::Shift; // shift key
     68        switch (arg.key)
     69        {
     70            case OIS::KC_RMENU:
     71            case OIS::KC_LMENU:
     72                modifiers_ &= ~KeyboardModifier::Alt;   // alt key
     73                break;
     74            case OIS::KC_RCONTROL:
     75            case OIS::KC_LCONTROL:
     76                modifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
     77                break;
     78            case OIS::KC_RSHIFT:
     79            case OIS::KC_LSHIFT:
     80                modifiers_ &= ~KeyboardModifier::Shift; // shift key
     81                break;
     82            default:;
     83        }
    6484
    65         KeyEvent evt(arg);
     85        KeyEvent evt(static_cast<KeyCode::ByEnum>(arg.key), Keyboard::getKeyText(arg), 0);
    6686        super::buttonReleased(evt);
    6787        return true;
    6888    }
     89
     90    /// A map which returns the corresponding chars for some key codes
     91    unsigned int Keyboard::getKeyText(const OIS::KeyEvent& arg)
     92    {
     93        switch (arg.key)
     94        {
     95            case OIS::KC_NUMPAD0:     return static_cast<unsigned int>('0');
     96            case OIS::KC_NUMPAD1:     return static_cast<unsigned int>('1');
     97            case OIS::KC_NUMPAD2:     return static_cast<unsigned int>('2');
     98            case OIS::KC_NUMPAD3:     return static_cast<unsigned int>('3');
     99            case OIS::KC_NUMPAD4:     return static_cast<unsigned int>('4');
     100            case OIS::KC_NUMPAD5:     return static_cast<unsigned int>('5');
     101            case OIS::KC_NUMPAD6:     return static_cast<unsigned int>('6');
     102            case OIS::KC_NUMPAD7:     return static_cast<unsigned int>('7');
     103            case OIS::KC_NUMPAD8:     return static_cast<unsigned int>('8');
     104            case OIS::KC_NUMPAD9:     return static_cast<unsigned int>('9');
     105            case OIS::KC_DECIMAL:     return static_cast<unsigned int>('.');
     106            case OIS::KC_DIVIDE:      return static_cast<unsigned int>('/');
     107            case OIS::KC_NUMPADENTER: return static_cast<unsigned int>('\n');
     108            default:                  return arg.text;
     109        }
     110    }
    69111}
  • code/branches/tutorial/src/libraries/core/input/Keyboard.h

    r7809 r8051  
    8383        static std::string getClassNameImpl() { return "Keyboard"; }
    8484
     85        static unsigned int getKeyText(const OIS::KeyEvent& arg);
     86
    8587        //! Bit mask representing keyboard modifiers
    8688        int modifiers_;
  • code/branches/tutorial/src/libraries/network/Host.cc

    r7801 r8051  
    3838namespace orxonox {
    3939
     40  static const std::string __CC_printRTT_group = "Stats";
    4041  static const std::string __CC_printRTT_name = "printRTT";
    4142
    4243  SetConsoleCommand("chat", &Host::Chat);
    43   SetConsoleCommand(__CC_printRTT_name, &Host::printRTT);
     44  SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
    4445
    4546  // Host*               Host::instance_=0;
     
    5556  //   assert(instance_==0);
    5657    instances_s.push_back(this);
    57     ModifyConsoleCommand(__CC_printRTT_name).setObject(this);
     58    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(this);
    5859    this->bIsActive_ = false;
    5960  }
     
    6768    assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() );
    6869    instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this ));
    69     ModifyConsoleCommand(__CC_printRTT_name).setObject(0);
     70    ModifyConsoleCommand(__CC_printRTT_group, __CC_printRTT_name).setObject(0);
    7071  }
    7172
  • code/branches/tutorial/src/libraries/tools/Shader.h

    r7976 r8051  
    3838#include <OgreCompositorInstance.h>
    3939
     40#include "util/MultiType.h"
    4041#include "util/OgreForwardRefs.h"
    4142#include "core/ViewportEventListener.h"
  • code/branches/tutorial/src/libraries/tools/Timer.cc

    r7401 r8051  
    3535
    3636#include <set>
     37
     38#include <boost/bimap.hpp>
    3739
    3840#include "util/Clock.h"
     
    4143#include "core/command/CommandExecutor.h"
    4244#include "core/command/Functor.h"
     45#include "tools/interfaces/TimeFactorListener.h"
    4346
    4447namespace orxonox
    4548{
    4649    SetConsoleCommand("delay", &delay).argumentCompleter(1, autocompletion::command());
     50    SetConsoleCommand("delayreal", &delayreal).argumentCompleter(1, autocompletion::command());
     51    SetConsoleCommand("killdelay", &killdelay);
    4752    SetConsoleCommand("killdelays", &killdelays);
    4853
    49     static std::set<Timer*> delaytimerset;
    50 
    51     /**
    52         @brief Console-command: Calls another console command after @a delay seconds.
     54    static boost::bimap<unsigned int, Timer*> delaytimers;
     55    static unsigned int delayHandleCounter = 0;
     56
     57    /**
     58        @brief Console-command: Calls another console command after @a delay seconds (game time).
    5359        @param delay The delay in seconds
    5460        @param command The console command
    55     */
    56     void delay(float delay, const std::string& command)
    57     {
    58         Timer* delaytimer = new Timer();
    59         delaytimerset.insert(delaytimer);
     61        @return The handle of the delayed command, can be used as argument for killdelay()
     62    */
     63    unsigned int delay(float delay, const std::string& command)
     64    {
     65        return addDelayedCommand(new Timer(), delay, command);
     66    }
     67
     68    /**
     69        @brief Console-command: Calls another console command after @a delay seconds (real time)
     70        @param delay The delay in seconds
     71        @param command The console command
     72        @return The handle of the delayed command, can be used as argument for killdelay()
     73    */
     74    unsigned int delayreal(float delay, const std::string& command)
     75    {
     76        return addDelayedCommand(new RealTimer(), delay, command);
     77    }
     78
     79    /**
     80        @brief Helper function, used by delay() and delayreal() to add a delayed command.
     81        @param timer The timer which will execute the command
     82        @param delay The delay in seconds
     83        @param command The console command
     84        @return The handle of the delayed command, can be used as argument for killdelay()
     85    */
     86    unsigned int addDelayedCommand(Timer* timer, float delay, const std::string& command)
     87    {
     88        delaytimers.insert(boost::bimap<unsigned int, Timer*>::value_type(++delayHandleCounter, timer));
    6089
    6190        const ExecutorStaticPtr& delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
    62         delayexecutor->setDefaultValues(delaytimer, command);
    63         delaytimer->setTimer(delay, false, delayexecutor);
     91        delayexecutor->setDefaultValues(timer, command);
     92        timer->setTimer(delay, false, delayexecutor);
     93
     94        return delayHandleCounter;
    6495    }
    6596
     
    73104        CommandExecutor::execute(command);
    74105        timer->destroy();
    75         delaytimerset.erase(timer);
     106        delaytimers.right.erase(timer);
    76107    }
    77108
     
    81112    void killdelays()
    82113    {
    83         for (std::set<Timer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
    84             (*it)->destroy();
    85 
    86         delaytimerset.clear();
     114        for (boost::bimap<unsigned int, Timer*>::left_map::iterator it = delaytimers.left.begin(); it != delaytimers.left.end(); ++it)
     115            it->second->destroy();
     116
     117        delaytimers.clear();
     118    }
     119
     120    /**
     121        @brief Console-command: Kills a delayed command with given handle.
     122    */
     123    void killdelay(unsigned int handle)
     124    {
     125        boost::bimap<unsigned int, Timer*>::left_map::iterator it = delaytimers.left.find(handle);
     126        if (it != delaytimers.left.end())
     127        {
     128            it->second->destroy();
     129            delaytimers.left.erase(it);
     130        }
    87131    }
    88132
     
    93137    {
    94138        this->init();
    95         RegisterObject(Timer);
     139        RegisterRootObject(Timer);
    96140    }
    97141
     
    106150    {
    107151        this->init();
    108         RegisterObject(Timer);
     152        RegisterRootObject(Timer);
    109153
    110154        this->setTimer(interval, bLoop, executor, bKillAfterCall);
     
    123167
    124168        this->time_ = 0;
     169    }
     170
     171    /**
     172        @brief Returns the current time factor of the game.
     173    */
     174    float Timer::getTimeFactor()
     175    {
     176        return TimeFactorListener::getTimeFactor();
    125177    }
    126178
     
    168220        }
    169221    }
     222
     223    ///////////////
     224    // RealTimer //
     225    ///////////////
     226    /// @copydoc Timer::Timer
     227    RealTimer::RealTimer()
     228    {
     229        RegisterObject(RealTimer);
     230    }
     231
     232    /// @copydoc Timer::Timer(float, bool, const ExecutorPtr&, bool)
     233    RealTimer::RealTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall) : Timer(interval, bLoop, executor, bKillAfterCall)
     234    {
     235        RegisterObject(RealTimer);
     236    }
     237
     238    /// Returns always 1 because RealTimer doesn't depend on the game time.
     239    float RealTimer::getTimeFactor()
     240    {
     241        return 1;
     242    }
    170243}
  • code/branches/tutorial/src/libraries/tools/Timer.h

    r7851 r8051  
    8181#include "core/OrxonoxClass.h"
    8282#include "core/command/Executor.h"
    83 #include "tools/interfaces/TimeFactorListener.h"
    8483
    8584namespace orxonox
    8685{
    87     void delay(float delay, const std::string& command);
    88     void killdelays();
     86    unsigned int delay(float delay, const std::string& command);
     87    unsigned int delayreal(float delay, const std::string& command);
     88
     89    unsigned int addDelayedCommand(Timer* timer, float delay, const std::string& command);
    8990    void executeDelayedCommand(Timer* timer, const std::string& command);
    9091
     92    void killdelay(unsigned int handle);
     93    void killdelays();
     94
    9195    /**
    92         @brief Timer is a helper class that executes a function after a given amount of time.
     96        @brief Timer is a helper class that executes a function after a given amount of seconds in game-time.
    9397
    9498        @see See @ref TimerExample "Timer.h" for an example.
     99
     100        The time interval of Timer depends on the game time, hence it stops if the game is paused or runs
     101        slower/faster if the game-speed is modified. See RealTimer for a timer class which doesn't depend
     102        on the game time.
    95103    */
    96     class _ToolsExport Timer : public TimeFactorListener
     104    class _ToolsExport Timer : virtual public OrxonoxClass
    97105    {
    98106        public:
     
    123131            void run();
    124132
    125             /// Re-starts the Timer: The executor will be called after @a interval seconds.
     133            /// Re-starts the timer: The executor will be called after @a interval seconds.
    126134            inline void startTimer()
    127135                { this->bActive_ = true; this->time_ = this->interval_; }
    128             /// Stops the Timer.
     136            /// Stops the timer.
    129137            inline void stopTimer()
    130138                { this->bActive_ = false; this->time_ = this->interval_; }
    131             /// Pauses the Timer - it will continue with the actual state if you call unpauseTimer().
     139            /// Pauses the timer - it will continue with the actual state if you call unpauseTimer().
    132140            inline void pauseTimer()
    133141                { this->bActive_ = false; }
    134             /// Unpauses the Timer - continues with the given state.
     142            /// Unpauses the timer - continues with the given state.
    135143            inline void unpauseTimer()
    136144                { this->bActive_ = true; }
    137             /// Returns true if the Timer is active (neither stopped nor paused).
     145            /// Returns true if the timer is active (neither stopped nor paused).
    138146            inline bool isActive() const
    139147                { return this->bActive_; }
    140             /// Returns the remaining time until the Timer calls the executor.
     148            /// Returns the remaining time until the timer calls the executor.
    141149            inline float getRemainingTime() const
    142150                { return static_cast<float>(this->time_ / 1000000.0f); }
    143             /// Increases the remaining time of the Timer by the given amount of time (in seconds).
     151            /// Increases the remaining time of the timer by the given amount of time (in seconds).
    144152            inline void addTime(float time)
    145153                { if (time > 0.0f) this->time_ += static_cast<long long>(time * 1000000.0f); }
    146             /// Decreases the remaining time of the Timer by the given amount of time (in seconds)
     154            /// Decreases the remaining time of the timer by the given amount of time (in seconds)
    147155            inline void removeTime(float time)
    148156                { if (time > 0.0f) this->time_ -= static_cast<long long>(time * 1000000.0f); }
     
    156164            void tick(const Clock& time);
    157165
     166        protected:
     167            virtual float getTimeFactor();
     168
    158169        private:
    159170            void init();
     
    163174            long long interval_;    //!< The time-interval in micro seconds
    164175            bool bLoop_;            //!< If true, the executor gets called every @a interval seconds
    165             bool bActive_;          //!< If true, the Timer ticks and calls the executor if the time's up
     176            bool bActive_;          //!< If true, the timer ticks and calls the executor if the time's up
    166177            bool bKillAfterCall_;   //!< If true the timer gets deleted after it expired and called the executor
    167178
    168179            long long time_;        //!< Internal variable, counting the time untill the next executor-call
    169180    };
     181
     182    /**
     183        @brief RealTimer is a helper class that executes a function after a given amount of seconds in real-time.
     184
     185        The time interval of RealTimer doesn't depend on the game time, it will also call the function
     186        if the game is paused. See Timer for a timer class that depends on the game time.
     187    */
     188    class _ToolsExport RealTimer : public Timer
     189    {
     190        public:
     191            RealTimer();
     192            RealTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
     193
     194        protected:
     195            virtual float getTimeFactor();
     196    };
    170197}
    171198
  • code/branches/tutorial/src/libraries/tools/ToolsPrereqs.h

    r7163 r8051  
    8585    class Mesh;
    8686    class ParticleInterface;
     87    class RealTimer;
    8788    class ResourceCollection;
    8889    class ResourceLocation;
  • code/branches/tutorial/src/orxonox/ChatInputHandler.cc

    r8000 r8051  
    2828
    2929#include "ChatInputHandler.h"
     30
     31#include <cassert>
     32#include <string>
     33#include <CEGUIWindow.h>
     34#include <CEGUIWindowManager.h>
     35#include <elements/CEGUIListbox.h>
     36#include <elements/CEGUIListboxItem.h>
     37#include <elements/CEGUIListboxTextItem.h>
     38
    3039#include "util/ScopedSingletonManager.h"
    3140#include "core/CoreIncludes.h"
    3241#include "core/GUIManager.h"
    33 #include "core/CorePrereqs.h"
    3442#include "core/command/ConsoleCommand.h"
    35 #include <CEGUIWindow.h>
    36 #include <elements/CEGUIListbox.h>
    37 #include <elements/CEGUIListboxItem.h>
    38 #include <elements/CEGUIListboxTextItem.h>
    39 #include <CEGUIWindowManager.h>
    40 #include <string>
     43#include "core/input/InputBuffer.h"
     44#include "core/input/InputManager.h"
     45#include "core/input/InputState.h"
     46#include "network/Host.h"
     47
     48#include "PlayerManager.h"
     49#include "infos/PlayerInfo.h"
    4150
    4251namespace orxonox
  • code/branches/tutorial/src/orxonox/ChatInputHandler.h

    r8000 r8051  
    3030#define _ChatInputHandler_H__
    3131
    32 /* std includes */
    33 #include <deque>
     32#include <OrxonoxPrereqs.h>
     33
    3434#include <string>
    35 #include <fstream>
    36 #include <iostream>
    37 #include <cassert>
    3835#include <CEGUIForwardRefs.h>
    3936#include <CEGUIcolour.h>
    4037
    41 /* project includes */
    42 #include <OrxonoxPrereqs.h>
    43 #include <core/BaseObject.h>
    44 #include <core/PathConfig.h>
    45 
    46 #include "core/input/InputBuffer.h"
    47 #include "core/input/InputManager.h"
    48 #include "core/input/InputState.h"
    49 
    50 #include <network/ChatListener.h>
    51 #include <PlayerManager.h>
    52 #include <infos/PlayerInfo.h>
    53 
    54 #include "../libraries/network/Host.h"
    55 #include <util/Singleton.h>
     38#include "util/Singleton.h"
     39#include "network/ChatListener.h"
    5640
    5741namespace orxonox // tolua_export
  • code/branches/tutorial/src/orxonox/LevelInfo.h

    r7804 r8051  
    109109            @return Returns the XML-filename (including *.oxw extension) of the Level.
    110110            */
    111             inline const std::string& getXMLFilename(void) { return this->xmlfilename_; } // tolua_export
     111            inline const std::string& getXMLFilename(void) const { return this->xmlfilename_; } // tolua_export
    112112
    113113        protected:
     
    212212    {
    213213        bool operator() (const LevelInfoItem* lhs, const LevelInfoItem* rhs) const
    214             { return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0; }
     214            {
     215                if(getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) == 0)
     216                    return getLowercase(lhs->getXMLFilename()).compare(getLowercase(rhs->getXMLFilename())) < 0;
     217                return getLowercase(lhs->getName()).compare(getLowercase(rhs->getName())) < 0;
     218            }
    215219    };
    216220   
  • code/branches/tutorial/src/orxonox/LevelManager.cc

    r7999 r8051  
    251251        // Iterate over all the found *.oxw files
    252252        COUT(3) << "Loading LevelInfos..." << std::endl;
     253        std::set<std::string> names;
    253254        for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
    254255        {
     
    277278                }
    278279
     280                // Warn about levels with the same name.
     281                if(!names.insert(info->getName()).second)
     282                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << std::endl;
     283
    279284                // Warn about multiple items so that it gets fixed quickly
    280285                if(availableLevels_.find(info) != availableLevels_.end())
    281286                {
    282                     COUT(2) << "Warning: Multiple levels with name '" << info->getName() << "' found!" << std::endl;
     287                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl;
    283288                    // Delete LevelInfoItem to avoid a dangling pointer
    284289                    delete info;
  • code/branches/tutorial/src/orxonox/LevelManager.h

    r7804 r8051  
    112112            // Helpers to allow fast access to the availableLevels list.
    113113            unsigned int nextIndex_; //! The next expected index to be accessed.
    114             std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The nex expected Level to be accessed.
     114            std::set<LevelInfoItem*, LevelInfoCompare>::iterator nextLevel_; //! The next expected Level to be accessed.
    115115
    116116            // config values
  • code/branches/tutorial/src/orxonox/gamestates/GSLevel.cc

    r7978 r8051  
    4646#include "LevelManager.h"
    4747#include "PlayerManager.h"
     48#include "GSRoot.h"
    4849
    4950namespace orxonox
     
    156157        COUT(0) << "Loading level..." << std::endl;
    157158        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
    158         Loader::open(startFile_);
     159        bool loaded = Loader::open(startFile_);
    159160
    160161        Core::getInstance().updateLastLevelTimestamp();
     162        if(!loaded)
     163            GSRoot::delayedStartMainMenu();
    161164    }
    162165
  • code/branches/tutorial/src/orxonox/gamestates/GSMainMenu.cc

    r7978 r8051  
    6868        RegisterRootObject(GSMainMenu);
    6969
    70         InputManager::getInstance().createInputState("MainMenuHackery", true, true)->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
     70        InputManager::getInstance().createInputState("MainMenuHackery")->setKeyHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
    7171
    7272        // create an empty Scene
  • code/branches/tutorial/src/orxonox/gamestates/GSRoot.cc

    r7935 r8051  
    3838#include "tools/interfaces/Tickable.h"
    3939
     40#include "GSLevel.h"
     41
    4042namespace orxonox
    4143{
     
    4547    static const std::string __CC_setPause_name = "setPause";
    4648    static const std::string __CC_pause_name = "pause";
     49
     50    /*static*/ bool GSRoot::startMainMenu_s = false;
    4751
    4852    SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
     
    98102    void GSRoot::update(const Clock& time)
    99103    {
     104        if(startMainMenu_s)
     105        {
     106            delayedStartMainMenu();
     107            startMainMenu_s = false;
     108        }
     109
    100110        for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
    101111        {
     
    175185            callStaticNetworkFunction(&TimeFactorListener::setTimeFactor, CLIENTID_UNKNOWN, factor_new);
    176186    }
     187
     188    /*static*/ void GSRoot::delayedStartMainMenu(void)
     189    {
     190        if(!startMainMenu_s)
     191            startMainMenu_s = true;
     192        else
     193            GSLevel::startMainMenu();
     194    }
     195
    177196}
  • code/branches/tutorial/src/orxonox/gamestates/GSRoot.h

    r7935 r8051  
    5454        void pause();
    5555
     56        static void delayedStartMainMenu(void);
     57
    5658    protected:
    5759        virtual void changedTimeFactor(float factor_new, float factor_old);
     
    6062        bool                  bPaused_;
    6163        float                 timeFactorPauseBackup_;
     64        static bool           startMainMenu_s;
    6265    };
    6366}
  • code/branches/tutorial/src/orxonox/gametypes/Gametype.cc

    r7801 r8051  
    3030
    3131#include "util/Math.h"
     32#include "core/Core.h"
    3233#include "core/CoreIncludes.h"
    3334#include "core/ConfigValueIncludes.h"
     
    386387                    if (allplayersready && hashumanplayers)
    387388                    {
    388                         this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
     389                        // If in developer's mode, there is no start countdown.
     390                        if(Core::getInstance().inDevMode())
     391                            this->gtinfo_->startCountdown_ = 0;
     392                        else
     393                            this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    389394                        this->gtinfo_->bStartCountdownRunning_ = true;
    390395                    }
  • code/branches/tutorial/src/orxonox/graphics/Model.cc

    r7183 r8051  
    6060    void Model::setConfigValues()
    6161    {
    62         SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableModelLoD", true)
     62        SetConfigValueExternal(bGlobalEnableLod_, "GraphicsSettings", "enableMeshLoD", true)
    6363            .description("Enable level of detail for models");
    6464    }
  • code/branches/tutorial/src/orxonox/overlays/InGameConsole.cc

    r8015 r8051  
    4949#include "core/ConfigValueIncludes.h"
    5050#include "core/command/ConsoleCommand.h"
    51 #include "core/GUIManager.h"
    5251#include "core/input/InputManager.h"
    5352#include "core/input/InputState.h"
     
    6059    const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
    6160
    62     SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole).addShortcut();
    63     SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole).addShortcut();
     61    SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
     62    SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
    6463
    6564    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
     
    534533        {
    535534            this->bActive_ = false;
    536             GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()"); // Notify the SheetManager in lua, that the console has been closed.
    537535            InputManager::getInstance().leaveState("console");
    538536            this->shell_->unregisterListener(this);
     
    611609    /*static*/ void InGameConsole::closeConsole()
    612610    {
    613         GUIManager::getInstance().getLuaState()->doString("inGameConsoleClosed()");  // Notify the SheetManager in lua, that the console has been closed, but not by ESC.
    614611        InGameConsole::getInstance().deactivate();
    615612    }
Note: See TracChangeset for help on using the changeset viewer.