Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8079


Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
116 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/cmake/tools/TargetUtilities.cmake

    r7818 r8079  
    266266    ADD_MODULE(${_target_name})
    267267    # Ensure that the main program depends on the module
    268     SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE STRING "" FORCE)
     268    SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE INTERNAL "")
    269269  ENDIF()
    270270
  • code/trunk/data/defaultConfig/keybindings.ini

    r7533 r8079  
    4242KeyF9=
    4343KeyG=greet
    44 KeyGrave="openConsole"
     44KeyGrave="InGameConsole openConsole"
    4545KeyH=
    4646KeyHome=
     
    127127KeyU=""
    128128KeyUP="scale 1 moveFrontBack"
    129 KeyUnassigned="openConsole"
     129KeyUnassigned="InGameConsole openConsole"
    130130KeyUnderline=
    131131KeyUnlabeled=
  • code/trunk/data/gui/configs/CEGUIConfig.xsd

    r5781 r8079  
    22<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    33
    4         <xsd:element name="CEGUIConfig" type="CEGUIConfigType"/>
     4    <xsd:element name="CEGUIConfig" type="CEGUIConfigType"/>
    55
    66    <xsd:simpleType name="LogLevel">
     
    1212        </xsd:restriction>
    1313    </xsd:simpleType>
    14    
    15         <xsd:complexType name="CEGUIConfigType">
    16                 <xsd:attribute name="Logfile" type="xsd:string" use="optional" default=""/>
    17                 <xsd:attribute name="Scheme" type="xsd:string" use="optional" default=""/>
    18                 <xsd:attribute name="DefaultFont" type="xsd:string" use="optional" default=""/>
    19                 <xsd:attribute name="Layout" type="xsd:string" use="optional" default=""/>
    20                 <xsd:attribute name="InitScript" type="xsd:string" use="optional" default=""/>
    21                 <xsd:attribute name="TerminateScript" type="xsd:string" use="optional" default=""/>
    22                 <xsd:attribute name="DefaultResourceGroup" type="xsd:string" use="optional"  default="" />
     14
     15    <xsd:complexType name="CEGUIConfigType">
     16        <xsd:attribute name="Logfile" type="xsd:string" use="optional" default=""/>
     17        <xsd:attribute name="Scheme" type="xsd:string" use="optional" default=""/>
     18        <xsd:attribute name="DefaultFont" type="xsd:string" use="optional" default=""/>
     19        <xsd:attribute name="Layout" type="xsd:string" use="optional" default=""/>
     20        <xsd:attribute name="InitScript" type="xsd:string" use="optional" default=""/>
     21        <xsd:attribute name="TerminateScript" type="xsd:string" use="optional" default=""/>
     22        <xsd:attribute name="DefaultResourceGroup" type="xsd:string" use="optional"  default="" />
    2323        <xsd:attribute name="LoggingLevel" type="LogLevel" use="optional"  default="Standard" />
    24         </xsd:complexType>
    25        
     24    </xsd:complexType>
     25
    2626</xsd:schema>
    2727
  • code/trunk/data/gui/layouts/GraphicsMenu.layout

    r7801 r8079  
    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/trunk/data/gui/schemes/GUIScheme.xsd

    r5781 r8079  
    11<?xml version="1.0" ?>
    22<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    3         <xsd:element name="GUIScheme" type="SchemeType" />
    4         <xsd:complexType name="SchemeType">
     3    <xsd:element name="GUIScheme" type="SchemeType" />
     4    <xsd:complexType name="SchemeType">
    55        <xsd:choice minOccurs="0" maxOccurs="unbounded">
    6                         <xsd:element name="Imageset" type="NamedDataType" />
     6            <xsd:element name="Imageset" type="NamedDataType" />
    77            <xsd:element name="ImagesetFromImage" type="NamedDataType" />
    8                         <xsd:element name="Font" type="NamedDataType" />
     8            <xsd:element name="Font" type="NamedDataType" />
    99            <xsd:element name="LookNFeel" type="FileDataType" />
    10                         <xsd:element name="WindowSet" type="WindowSetType" />
    11                         <xsd:element name="WindowRendererSet" type="WindowRendererSetType" />
    12                         <xsd:element name="WindowAlias" type="WindowAliasType" />
     10            <xsd:element name="WindowSet" type="WindowSetType" />
     11            <xsd:element name="WindowRendererSet" type="WindowRendererSetType" />
     12            <xsd:element name="WindowAlias" type="WindowAliasType" />
    1313            <xsd:element name="FalagardMapping" type="FalagardMapType" />
    14                 </xsd:choice>
    15                 <xsd:attribute name="Name" type="xsd:string" use="required" />
    16         </xsd:complexType>
    17         <xsd:complexType name="WindowSetType">
    18                 <xsd:sequence>
     14        </xsd:choice>
     15        <xsd:attribute name="Name" type="xsd:string" use="required" />
     16    </xsd:complexType>
     17    <xsd:complexType name="WindowSetType">
     18        <xsd:sequence>
    1919            <xsd:element name="WindowFactory" type="WindowFactoryType" minOccurs="0" maxOccurs="unbounded" />
    20                 </xsd:sequence>
    21                 <xsd:attribute name="Filename" type="xsd:string" use="required" />
    22         </xsd:complexType>
    23         <xsd:complexType name="WindowRendererSetType">
    24                 <xsd:sequence>
     20        </xsd:sequence>
     21        <xsd:attribute name="Filename" type="xsd:string" use="required" />
     22    </xsd:complexType>
     23    <xsd:complexType name="WindowRendererSetType">
     24        <xsd:sequence>
    2525            <xsd:element name="WindowRendererFactory" type="WindowRendererFactoryType" minOccurs="0" maxOccurs="unbounded" />
    26                 </xsd:sequence>
    27                 <xsd:attribute name="Filename" type="xsd:string" use="required" />
    28         </xsd:complexType>
     26        </xsd:sequence>
     27        <xsd:attribute name="Filename" type="xsd:string" use="required" />
     28    </xsd:complexType>
    2929    <xsd:complexType name="FileDataType">
    3030        <xsd:attribute name="Filename" type="xsd:string" use="required" />
    3131        <xsd:attribute name="ResourceGroup" type="xsd:string" use="optional"  default="" />
    3232    </xsd:complexType>
    33         <xsd:complexType name="NamedDataType">
    34                 <xsd:attribute name="Name" type="xsd:string" use="required" />
    35                 <xsd:attribute name="Filename" type="xsd:string" use="required" />
    36                 <xsd:attribute name="ResourceGroup" type="xsd:string" use="optional"  default="" />
    37         </xsd:complexType>
    38         <xsd:complexType name="WindowFactoryType">
    39                 <xsd:attribute name="Name" type="xsd:string" use="required" />
    40         </xsd:complexType>
    41         <xsd:complexType name="WindowRendererFactoryType">
    42                 <xsd:attribute name="Name" type="xsd:string" use="required" />
    43         </xsd:complexType>
    44         <xsd:complexType name="WindowAliasType">
    45                 <xsd:attribute name="Alias" type="xsd:string" use="required" />
    46                 <xsd:attribute name="Target" type="xsd:string" use="required" />
    47         </xsd:complexType>
     33    <xsd:complexType name="NamedDataType">
     34        <xsd:attribute name="Name" type="xsd:string" use="required" />
     35        <xsd:attribute name="Filename" type="xsd:string" use="required" />
     36        <xsd:attribute name="ResourceGroup" type="xsd:string" use="optional"  default="" />
     37    </xsd:complexType>
     38    <xsd:complexType name="WindowFactoryType">
     39        <xsd:attribute name="Name" type="xsd:string" use="required" />
     40    </xsd:complexType>
     41    <xsd:complexType name="WindowRendererFactoryType">
     42        <xsd:attribute name="Name" type="xsd:string" use="required" />
     43    </xsd:complexType>
     44    <xsd:complexType name="WindowAliasType">
     45        <xsd:attribute name="Alias" type="xsd:string" use="required" />
     46        <xsd:attribute name="Target" type="xsd:string" use="required" />
     47    </xsd:complexType>
    4848    <xsd:complexType name="FalagardMapType">
    4949        <xsd:attribute name="WindowType" type="xsd:string" use="required" />
    5050        <xsd:attribute name="TargetType" type="xsd:string" use="required" />
    51                 <xsd:attribute name="Renderer" type="xsd:string" use="required" />
     51        <xsd:attribute name="Renderer" type="xsd:string" use="required" />
    5252        <xsd:attribute name="LookNFeel" type="xsd:string" use="required" />
    5353    </xsd:complexType>
  • code/trunk/data/gui/schemes/OrxonoxLook.scheme

    r7887 r8079  
    11<?xml version="1.0" ?>
    22<GUIScheme Name="OrxonoxLook">
    3         <Imageset Name="OrxonoxLook" Filename="OrxonoxLook.imageset" />
    4         <LookNFeel Filename="OrxonoxLook.looknfeel" />
    5         <WindowRendererSet Filename="CEGUIFalagardWRBase" />
     3    <Imageset Name="OrxonoxLook" Filename="OrxonoxLook.imageset" />
     4    <LookNFeel Filename="OrxonoxLook.looknfeel" />
     5    <WindowRendererSet Filename="CEGUIFalagardWRBase" />
    66
    77    <!-- Standard widgets -->
     
    4545    <FalagardMapping WindowType="OrxonoxLook/Tooltip"                  TargetType="CEGUI/Tooltip"           Renderer="Falagard/Tooltip"           LookNFeel="OrxonoxLook/Tooltip" />
    4646    <FalagardMapping WindowType="OrxonoxLook/Tree"                     TargetType="CEGUI/Tree"              Renderer="Falagard/Tree"              LookNFeel="OrxonoxLook/Tree" />
    47    
     47
    4848    <!-- Additional widgets -->
    4949    <FalagardMapping WindowType="OrxonoxLook/AlternateProgressBar"        TargetType="CEGUI/ProgressBar"       Renderer="Falagard/ProgressBar"       LookNFeel="OrxonoxLook/AltProgressBar" />
  • code/trunk/data/gui/schemes/TaharezGreenLook.scheme

    r6746 r8079  
    11<?xml version="1.0" ?>
    22<GUIScheme Name="TaharezGreenLook">
    3         <Imageset Name="TaharezGreenLook" Filename="TaharezGreenLook.imageset" />
    4         <LookNFeel Filename="TaharezGreenLook.looknfeel" />
    5         <WindowRendererSet Filename="CEGUIFalagardWRBase" />
     3    <Imageset Name="TaharezGreenLook" Filename="TaharezGreenLook.imageset" />
     4    <LookNFeel Filename="TaharezGreenLook.looknfeel" />
     5    <WindowRendererSet Filename="CEGUIFalagardWRBase" />
    66
    77    <!-- Standard widgets -->
     
    4545    <FalagardMapping WindowType="TaharezGreenLook/Tooltip"                  TargetType="CEGUI/Tooltip"           Renderer="Falagard/Tooltip"           LookNFeel="TaharezGreenLook/Tooltip" />
    4646    <FalagardMapping WindowType="TaharezGreenLook/Tree"                     TargetType="CEGUI/Tree"              Renderer="Falagard/Tree"              LookNFeel="TaharezGreenLook/Tree" />
    47    
     47
    4848    <!-- Additional widgets -->
    4949    <FalagardMapping WindowType="TaharezGreenLook/AlternateProgressBar"        TargetType="CEGUI/ProgressBar"       Renderer="Falagard/ProgressBar"       LookNFeel="TaharezGreenLook/AltProgressBar" />
  • code/trunk/data/gui/schemes/TaharezLook.scheme

    r6746 r8079  
    11<?xml version="1.0" ?>
    22<GUIScheme Name="TaharezLook">
    3         <Imageset Name="TaharezLook" Filename="TaharezLook.imageset" />
    4         <LookNFeel Filename="TaharezLook.looknfeel" />
    5         <WindowRendererSet Filename="CEGUIFalagardWRBase" />
     3    <Imageset Name="TaharezLook" Filename="TaharezLook.imageset" />
     4    <LookNFeel Filename="TaharezLook.looknfeel" />
     5    <WindowRendererSet Filename="CEGUIFalagardWRBase" />
    66
    77    <!-- Standard widgets -->
     
    4545    <FalagardMapping WindowType="TaharezLook/Tooltip"                  TargetType="CEGUI/Tooltip"           Renderer="Falagard/Tooltip"           LookNFeel="TaharezLook/Tooltip" />
    4646    <FalagardMapping WindowType="TaharezLook/Tree"                     TargetType="CEGUI/Tree"              Renderer="Falagard/Tree"              LookNFeel="TaharezLook/Tree" />
    47    
     47
    4848    <!-- Additional widgets -->
    4949    <FalagardMapping WindowType="TaharezLook/AlternateProgressBar"        TargetType="CEGUI/ProgressBar"       Renderer="Falagard/ProgressBar"       LookNFeel="TaharezLook/AltProgressBar" />
  • code/trunk/data/gui/scripts/AudioMenu.lua

    r7689 r8079  
    22
    33local P = createMenuSheet("AudioMenu")
    4 
    5 P.buttonList = {}
    6 
    7 function P.onShow()
    8     P.oldindex = -2
    9     P.index = -1
    10 end
    114
    125function P.onLoad()
     
    5043    end
    5144
    52     local item = {
     45    P:setButton(1, 1, {
    5346            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
    54             ["function"]  = P.AudioBackButton_clicked
    55     }
    56     P.buttonList[1] = item
     47            ["callback"]  = P.AudioBackButton_clicked
     48    })
    5749end
    5850
     
    185177end
    186178
    187 function P.onKeyPressed()
    188     buttonIteratorHelper(P.buttonList, code, P, 1, 1)
    189 end
    190 
    191179return P
    192180
  • code/trunk/data/gui/scripts/ControlsMenu.lua

    r7689 r8079  
    22
    33local P = createMenuSheet("ControlsMenu")
    4 P.buttonList = {}
    54P.loadAlong = { "MouseControlsMenu", "KeyBindMenu" }
    65
    76function P.onLoad()
    8     P.multiplayerMode = "startClient" 
     7    P.multiplayerMode = "startClient"
    98
    109    --buttons are arranged in a 3x1 matrix:
    11     local item = {
     10    P:setButton(1, 1, {
    1211            ["button"] = winMgr:getWindow("orxonox/MouseControlsButton"),
    13             ["function"]  = P.ControlsMouseControlsButton_clicked
    14     }
    15     P.buttonList[1] = item
     12            ["callback"]  = P.ControlsMouseControlsButton_clicked
     13    })
    1614
    17     local item = {
     15    P:setButton(2, 1, {
    1816            ["button"] = winMgr:getWindow("orxonox/KeybindingsButton"),
    19             ["function"]  = P.ControlsKeyboardControlsButton_clicked
    20     }
    21     P.buttonList[2] = item
     17            ["callback"]  = P.ControlsKeyboardControlsButton_clicked
     18    })
    2219
    23     local item = {
     20    P:setButton(3, 1, {
    2421            ["button"] = winMgr:getWindow("orxonox/ControlsBackButton"),
    25             ["function"]  = P.ControlsBackButton_clicked
    26     }
    27     P.buttonList[3] = item
    28 
    29 end
    30 
    31 function P.onShow()
    32     --indices to iterate through buttonlist
    33     P.oldindex = -2
    34     P.index = -1
     22            ["callback"]  = P.ControlsBackButton_clicked
     23    })
    3524end
    3625
     
    4736end
    4837
    49 function P.onKeyPressed()
    50     buttonIteratorHelper(P.buttonList, code, P, 3, 1)
    51 end
    52 
    5338return P
    5439
  • code/trunk/data/gui/scripts/CreditsMenu.lua

    r7732 r8079  
    33local P = createMenuSheet("CreditsMenu")
    44
    5 P.buttonList = {}
    65P.scrollbarWidth = 13
    76
    87function P.onLoad()
    9     local item = {
     8    P:setButton(1, 1, {
    109            ["button"] = winMgr:getWindow("orxonox/CreditsBackButton"),
    11             ["function"]  = P.CreditsBackButton_clicked
    12     }
    13     P.buttonList[1] = item
     10            ["callback"]  = P.CreditsBackButton_clicked
     11    })
    1412end
    1513
    1614function P.onShow()
    17     --indices to iterate through buttonlist
    18     P.oldindex = -2
    19     P.index = -1
    20 
    2115    local description = winMgr:getWindow("orxonox/CreditsText")
    2216    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
     
    3327end
    3428
    35 function P.onKeyPressed()
    36     buttonIteratorHelper(P.buttonList, code, P, 1, 1)
    37 end
    38 
    3929return P
    4030
  • code/trunk/data/gui/scripts/DecisionPopup.lua

    r7726 r8079  
    33local P = createMenuSheet("DecisionPopup")
    44
    5 P.buttonList = {}
    6 
    7 function P.onShow()
    8     --indices to iterate through buttonlist
    9     P.oldindex = -2
    10     P.index = -1
    11 end
    12 
    135function P.onLoad()
    146
    157    --button are arranged in a 1x2 matrix
    16     local item = {
     8    P:setButton(1, 1, {
    179            ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_yes"),
    18             ["function"]  = P.button_yes
    19     }
    20     P.buttonList[1] = item
     10            ["callback"]  = P.button_yes
     11    })
    2112
    22     local item = {
     13    P:setButton(1, 2, {
    2314            ["button"] = winMgr:getWindow("orxonox/DecisionPopup_button_no"),
    24             ["function"]  = P.button_no
    25     }
    26     P.buttonList[2] = item
     15            ["callback"]  = P.button_no
     16    })
     17end
    2718
     19function P.onShow()
     20    P:setSelection(1, 1)
    2821end
    2922
     
    5144end
    5245
    53 function P.onKeyPressed()
    54     buttonIteratorHelper(P.buttonList, code, P, 1, 2)
    55 end
    56 
    5746return P
    5847
  • code/trunk/data/gui/scripts/GUISheet.lua

    r7689 r8079  
    1616end
    1717
     18-- Override this function if you need to do work on show
     19function P:onShow()
     20end
     21
     22-- Override this function if you need to do work on hide
     23function P:onHide()
     24end
     25
     26-- Override this function if you need to do work on quit
     27function P:onQuit()
     28end
     29
     30-- Override this function if you want to react on keystrokes
     31function P:onKeyPressed()
     32end
     33
     34-- Override this function if you want to update the gui after the window was resized
     35function P:onWindowResized()
     36end
     37
    1838-- show function for the GUI
    1939function P:show()
     
    2141    self.bVisible = true
    2242
     43    -- set the selected button's state
     44    self:setSelectedButtonsStateToSelected()
     45
    2346    self:onShow()
    24 end
    25 
    26 -- Override this function if you need to do work on show
    27 function P:onShow()
    2847end
    2948
     
    3655end
    3756
    38 -- Override this function if you need to do work on hide
    39 function P:onHide()
    40 end
    41 
    42 -- Override this function if you need to do work just after the sheet has been hidden
    43 function P:afterHide()
     57function P:quit()
     58    -- reset the selected button
     59    if self.buttons then
     60        self:resetSelection()
     61    end
     62
     63    self:onQuit()
    4464end
    4565
     
    6484end
    6585
    66 function P:onKeyPressed(e)
     86-- Handles key pressed while the gui sheed is displayed
     87function P:keyPressed()
     88    if self.buttons then
     89        if code == "208" then     -- key down
     90            self:moveSelectionRow(1)
     91        elseif code == "200" then -- key up
     92            self:moveSelectionRow(-1)
     93        elseif code == "205" then -- key right
     94            self:moveSelectionColumn(1)
     95        elseif code == "203" then -- key left
     96            self:moveSelectionColumn(-1)
     97        elseif code == "28" or code == "156"  then -- key enter or key numpad enter
     98            self:pressSelectedButton()
     99        end
     100    end
     101
     102    self:onKeyPressed()
     103end
     104
     105function P:windowResized()
     106    self:onWindowResized()
     107end
     108
     109
     110-------------------------------------------------------------------------------
     111-- Keyboard control -----------------------------------------------------------
     112-------------------------------------------------------------------------------
     113
     114-- Initializes the buttons table, used to control the menu with the keyboard
     115function P:initButtons(rows, columns)
     116    self.rows = rows
     117    self.columns = columns
     118    self.buttons = {}
     119    self.selectedRow = 0
     120    self.selectedColumn = 0
     121    self.ratio = 1
     122end
     123
     124-- ratio: the button's with divided by the button's height (used to calculate distance between buttons - adjust this until you get the desired behavior)
     125function P:setRatio(ratio)
     126    self.ratio = ratio
     127end
     128
     129-- Defines the button for a given position in the table. The upper-left button is at position (1, 1)
     130function P:setButton(row, column, button)
     131    if not self.buttons then
     132        -- init the table
     133        self:initButtons(row, column)
     134    elseif row > self.rows or column > self.columns then
     135        -- rearrange the table
     136        local maxRows = math.max(self.rows, row)
     137        local maxColumns = math.max(self.columns, column)
     138
     139        for r = self.rows, 1, -1 do
     140            for c = self.columns, 1, -1 do
     141                local b = self:getButton(r, c)
     142                if b then
     143                    self.buttons[(r - 1) * self.columns + (c - 1)] = nil
     144                    self.buttons[(r - 1) * maxColumns + (c - 1)] = b
     145                end
     146            end
     147        end
     148
     149        self.rows = maxRows
     150        self.columns = maxColumns
     151    end
     152
     153    self.buttons[(row - 1) * self.columns + (column - 1)] = button
     154end
     155
     156-- Returns the button at a given position in the table. The upper-left button is at position (1, 1)
     157function P:getButton(row, column)
     158    if self.buttons then
     159        return self.buttons[(row - 1) * self.columns + (column - 1)]
     160    else
     161        return nil
     162    end
     163end
     164
     165-- Returns the selected button
     166function P:getSelectedButton()
     167    if self:hasSelection() then
     168        return self:getButton(self.selectedRow, self.selectedColumn)
     169    else
     170        return nil
     171    end
     172end
     173
     174-- Presses the selected button if any
     175function P:pressSelectedButton()
     176    if self:getSelectedButton() then
     177        self.pressedEnter = true
     178        self:getSelectedButton().callback()
     179        self.pressedEnter = false
     180    end
     181end
     182
     183-- Sets the selection to a given row and column. The upper-left button is at position (1, 1)
     184function P:setSelection(row, column)
     185    if not self.buttons then
     186        return
     187    end
     188
     189    assert(row > 0 and column > 0 and row <= self.rows and column <= self.columns, "(" .. row .. "/" .. column .. ") is not in the valid bounds of the table (1/1)-(" .. self.rows .. "/" .. self.columns .. ")")
     190
     191    self:setSelectedButtonsStateToNormal()
     192
     193    self.selectedRow = row
     194    self.selectedColumn = column
     195
     196    self:setSelectedButtonsStateToSelected()
     197end
     198
     199-- Sets the selection to the button closest to the given row and column. The upper-left button is at position (1, 1)
     200function P:setSelectionNear(row, column)
     201    if not self.buttons then
     202        return
     203    end
     204
     205    assert(row > 0 and column > 0 and row <= self.rows and column <= self.columns, "(" .. row .. "/" .. column .. ") is not in the valid bounds of the table (1/1)-(" .. self.rows .. "/" .. self.columns .. ")")
     206
     207    if self:getButton(row, column) then
     208        self:setSelection(row, column)
     209    else
     210        local min = 1000000
     211        local minRow, minColumn
     212
     213        for r = 1, self.rows do
     214            for c = 1, self.columns do
     215                if self:getButton(r, c) then
     216                    local distance = math.sqrt((row - r)^2 + ((column - c) * self.ratio)^2)
     217                    if distance < min then
     218                        min = distance; minRow = r; minColumn = c
     219                    end
     220                end
     221            end
     222        end
     223
     224        if minRow and minColumn then
     225            self:setSelection(minRow, minColumn)
     226        else
     227            self:resetSelection()
     228        end
     229    end
     230end
     231
     232-- Moves the selection by a given number of rows (a positive value means down, a negative value means up)
     233function P:moveSelectionRow(relRow)
     234    self:moveSelection(relRow, "selectedRow", "selectedColumn", "rows", "columns", true)
     235end
     236
     237-- Moves the selection by a given number of columns (a positive value means right, a negative value means left)
     238function P:moveSelectionColumn(relColumn)
     239    self:moveSelection(relColumn, "selectedColumn", "selectedRow", "columns", "rows", false)
     240end
     241
     242-- Generic move function, the values are determined at runtime depending on the arguments
     243function P:moveSelection(relMove, selectedThis, selectedOther, limitThis, limitOther, isRow)
     244    if not self.buttons then
     245        return
     246    end
     247
     248    -- if there's no selection yet, prepare it such that the selection enters the table from the desired side
     249    if self.selectedRow > 0 or self.selectedColumn > 0 then
     250        self:setSelectedButtonsStateToNormal()
     251    else
     252        if relMove > 0 then
     253            self[selectedThis] = 0
     254            self[selectedOther] = 1
     255        elseif relMove < 0 then
     256            self[selectedThis] = self[limitThis] + 1
     257            self[selectedOther] = 1
     258        else
     259            return
     260        end
     261    end
     262
     263    -- move the selection according to the parameters
     264    self[selectedThis] = self[selectedThis] + relMove
     265
     266    -- wrap around on overflow or underflow
     267    while self[selectedThis] > self[limitThis] do self[selectedThis] = self[selectedThis] - self[limitThis] end
     268    while self[selectedThis] <= 0              do self[selectedThis] = self[selectedThis] + self[limitThis] end
     269
     270    -- if the button is deactivated, search the button closest to the desired location
     271    if self:getSelectedButton() == nil then
     272        local min = 1000000
     273        local minV1, minV2
     274        local limit, step
     275
     276        if relMove > 0 then
     277            limit = self[limitThis]
     278            step = 1
     279        else
     280            limit = 1
     281            step = -1
     282        end
     283
     284        for v1 = self[selectedThis], limit, step do
     285            for v2 = 1, self[limitOther] do
     286                local button
     287                if isRow == true then
     288                    button = self:getButton(v1, v2)
     289                else
     290                    button = self:getButton(v2, v1)
     291                end
     292                if button then
     293                    local distance
     294                    if isRow == true then
     295                        distance = math.sqrt((self[selectedThis] - v1)^2 + ((self[selectedOther] - v2) * self.ratio)^2)
     296                    else
     297                        distance = math.sqrt(((self[selectedThis] - v1) * self.ratio)^2 + (self[selectedOther] - v2)^2)
     298                    end
     299                    if distance < min then
     300                        min = distance; minV1 = v1; minV2 = v2
     301                    end
     302                end
     303            end
     304        end
     305
     306        if minV1 and minV2 then
     307            self[selectedThis] = minV1
     308            self[selectedOther] = minV2
     309        elseif self:hasButtons() then
     310            -- no suitable button found - wrap around and search again
     311            if relMove > 0 then
     312                self[selectedThis] = 0
     313            else
     314                self[selectedThis] = self[limitThis] + 1
     315            end
     316            self:moveSelection(relMove, selectedThis, selectedOther, limitThis, limitOther, isRow)
     317        end
     318    end
     319
     320    self:setSelectedButtonsStateToSelected()
     321end
     322
     323-- Resets the selection
     324function P:resetSelection()
     325    self:setSelectedButtonsStateToNormal()
     326
     327    self.selectedRow = 0
     328    self.selectedColumn = 0
     329end
     330
     331-- Checks if there's at least one button in the table
     332function P:hasButtons()
     333    local count = 0
     334    for r = 1, self.rows do
     335        for c = 1, self.columns do
     336            if self:getButton(r, c) then
     337                count = count + 1
     338            end
     339        end
     340    end
     341
     342    return (count > 0)
     343end
     344
     345-- Determines if a button is selected
     346function P:hasSelection()
     347    if self.selectedRow and self.selectedRow > 0 and self.selectedColumn and self.selectedColumn > 0 then
     348        return true
     349    else
     350        return false
     351    end
     352end
     353
     354-- Sets the selected button's state to normal
     355function P:setSelectedButtonsStateToNormal()
     356    self:setSelectedButtonsState("Normal")
     357end
     358
     359-- Sets the selected button's state to selected
     360function P:setSelectedButtonsStateToSelected()
     361    self:setSelectedButtonsState("Selected")
     362end
     363
     364-- Sets the selected button's state to pushed
     365function P:setSelectedButtonsStateToPushed()
     366    self:setSelectedButtonsState("Pushed")
     367end
     368
     369-- Sets the selected button's state
     370function P:setSelectedButtonsState(state)
     371    if self:getSelectedButton() then
     372        local element = self:getSelectedButton().button
     373        local offset = getElementStateOffset(element)
     374
     375        if offset then
     376            element:setProperty("NormalImageRightEdge",  string.sub(element:getProperty("NormalImageRightEdge"),  1, offset) .. state)
     377            element:setProperty("NormalImageLeftEdge",   string.sub(element:getProperty("NormalImageLeftEdge"),   1, offset) .. state)
     378            element:setProperty("NormalImageBackground", string.sub(element:getProperty("NormalImageBackground"), 1, offset) .. state)
     379        end
     380    end
     381end
     382
     383-- Gets the offset of the button's current state
     384function getElementStateOffset(element)
     385    local property = element:getProperty("NormalImageRightEdge")
     386
     387    if string.sub(property, string.len(property) - 5, string.len(property)) == "Normal" then
     388        return -7
     389    elseif string.sub(property, string.len(property) - 7, string.len(property)) == "Selected" then
     390        return -9
     391    elseif string.sub(property, string.len(property) - 5, string.len(property)) == "Pushed" then
     392        return -7
     393    else
     394        return nil
     395    end
    67396end
    68397
  • code/trunk/data/gui/scripts/GUITools.lua

    r7913 r8079  
    5454    return height
    5555end
    56 
    57 --function to iterate through a menu sheet by using arrowkeys
    58 
    59 --@arguments:
    60 --  list: 2-dimensional table, arguments are items that contain a button and its function
    61 --        !!note: each button can only be in the list once!!
    62 --  code: code of any key on the keyboard
    63 --  P: menusheet
    64 --  n: number of rows of the buttontable
    65 --  m: number of colums of the buttontable
    66 
    67 function buttonIteratorHelper(list, code, P, n, m)
    68 
    69     --after a key (down,up,left,right) is pressed the index of the current button has to be updated   
    70 
    71     --key down
    72     if code == "208" then
    73         if P.index < 0 then     -- initial status
    74             P.index = 0
    75             P.oldindex = -1
    76         else
    77             P.oldindex = P.index
    78             P.index = (P.index + m) % (m*n)     --modulo operation works as a "wrap around" in the button menu
    79                                                
    80             while list[P.index+1] == nil do     
    81                 P.oldindex = P.index
    82                 P.index = (P.index + m) % (m*n)
    83             end
    84         end
    85 
    86     --key up
    87     elseif code == "200" then
    88         if P.index < 0 then
    89             P.index = 0
    90             P.oldindex = -1
    91         elseif(P.index == 0) then
    92             P.oldindex = P.index
    93             P.index = m*n-m
    94 
    95             while list[P.index+1] == nil do
    96                 P.oldindex = P.index
    97                 P.index = (P.index-m)%(m*n)
    98             end
    99         else
    100             P.oldindex = P.index
    101             P.index = (P.index -m) % (m*n)
    102 
    103             while list[P.index+1] == nil do
    104                 P.oldindex = P.index
    105                 P.index = (P.index-m)%(m*n)
    106             end
    107         end
    108 
    109     --key right
    110     elseif code == "205" then
    111         if P.index < 0 then
    112             P.index = 0
    113             P.oldindex = -1
    114         elseif (P.index+1) % m == 0 then     -- we are at the right-end of a row
    115             P.oldindex = P.index
    116             P.index = P.index + 1 -m
    117 
    118             while list[P.index+1] == nil do
    119                 P.oldindex = P.index
    120                 P.index = P.index + 1
    121             end
    122         else
    123             P.oldindex = P.index
    124             P.index = P.index + 1
    125 
    126             while list[P.index+1] == nil do
    127                 if (P.index+1) % m == 0 then     -- we are at the right-end of a row
    128                     P.oldindex = P.index
    129                     P.index = P.index + 1-m
    130 
    131                 else   
    132                     P.oldindex = P.index
    133                     P.index = P.index + 1
    134                 end
    135             end
    136         end   
    137 
    138     --key left
    139     elseif code == "203" then
    140         if P.index < 0 then
    141             P.index = 0
    142             P.oldindex = -1
    143         elseif P.index % m == 0 then         -- we are at the left-end of a row
    144             P.oldindex = P.index
    145             P.index = P.index +m-1
    146 
    147             while list[P.index+1] == nil do
    148                 P.oldindex = P.index
    149                 P.index = P.index -1
    150             end
    151         else
    152             P.oldindex = P.index
    153             P.index = P.index -1
    154 
    155             while list[P.index+1] == nil do
    156                 if P.index % m == 0 then     -- we are at the left-end of a row
    157                     P.oldindex = P.index
    158                     P.index = P.index -1 + m
    159                 else               
    160                     P.oldindex = P.index
    161                     P.index = P.index -1
    162                 end
    163             end   
    164         end
    165     end
    166        
    167     --to update the new current button
    168     if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
    169 
    170         local system = CEGUI.System:getSingleton()
    171         local window = winMgr:getWindow("orxonox/MainMenuBackground")
    172 
    173         local item = list[P.index+1]
    174         local child = item["button"]
    175         local s = child:getProperty("NormalImageRightEdge")
    176 
    177         --teste ob der Button nicht schon gehighlightet ist
    178         if string.sub(s,string.len(s)-8,string.len(s)) == "Highlight" then
    179             --nop
    180         else
    181             child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
    182             child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
    183             child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
    184             if P.oldindex >= 0 then
    185                 if list[P.oldindex+1] ~= nil then
    186                     local item = list[P.oldindex+1]
    187                     local oldChild = item["button"]
    188                     oldChild:setProperty("NormalImageRightEdge", string.sub(oldChild:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
    189                     oldChild:setProperty("NormalImageLeftEdge", string.sub(oldChild:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
    190                     oldChild:setProperty("NormalImageBackground", string.sub(oldChild:getProperty("NormalImageBackground"),1,-10) .. "Normal")
    191                 end
    192             end
    193         end
    194 
    195         --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"
    196         local i = 1
    197         while i < (n*m) do
    198             if i == P.index +1 then
    199                 i = i+1
    200             else
    201                 if list[i] ~= nil then
    202                 local item = list[i]
    203                 local child = item["button"]
    204                 local s = child:getProperty("NormalImageRightEdge")
    205                     if string.sub(s,string.len(s)-8,string.len(s)) == "Highlight" then
    206                         child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
    207                         child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
    208                         child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
    209                     end
    210                 end
    211             end
    212                 i=i+1
    213         end
    214     end 
    215 
    216     --enter
    217     if code == "28" and P.index >= 0 then
    218         local item = list[P.index+1]
    219         local child = item["button"]
    220         child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
    221         child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
    222         child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
    223 
    224         local foo = item["function"]
    225         foo()
    226     end
    227 
    228 end
    229 
    230 --write index and oldindex on the console
    231 --works like buttonIteratorHelper
    232 function indexTester(list,code,P,n,m)
    233     --key down
    234     if code == "208" then
    235         if P.index < 0 then     -- initial status
    236             P.index = 0
    237             P.oldindex = -1
    238         else
    239             P.oldindex = P.index
    240             P.index = (P.index + m) % (m*n)
    241 
    242             while list[P.index+1] == nil do
    243                 P.oldindex = P.index
    244                 P.index = (P.index + m) % (m*n)
    245             end
    246         end
    247 
    248     --key up
    249     elseif code == "200" then
    250         if P.index < 0 then
    251             P.index = 0
    252             P.oldindex = -1
    253         elseif(P.index == 0) then
    254             P.oldindex = P.index
    255             P.index = m*n-m
    256 
    257             while list[P.index+1] == nil do
    258                 P.oldindex = P.index
    259                 P.index = (P.index-m)%(m*n)
    260             end
    261         else
    262             P.oldindex = P.index
    263             P.index = (P.index -m) % (m*n)
    264 
    265             while list[P.index+1] == nil do
    266                 P.oldindex = P.index
    267                 P.index = P.index -m
    268             end
    269         end
    270 
    271     --key right
    272     elseif code == "205" then
    273         if P.index < 0 then
    274             P.index = 0
    275             P.oldindex = -1
    276         elseif (P.index+1) % m == 0 then     -- we are at the right-end of a row
    277             P.oldindex = P.index
    278             P.index = P.index + 1 -m
    279 
    280             while list[P.index+1] == nil do
    281                 P.oldindex = P.index
    282                 P.index = P.index + 1
    283             end
    284         else
    285             P.oldindex = P.index
    286             P.index = P.index + 1
    287 
    288             while list[P.index+1] == nil do
    289                 if (P.index+1) % m == 0 then     -- we are at the right-end of a row
    290                     P.oldindex = P.index
    291                     P.index = P.index + 1-m
    292 
    293                 else   
    294                     P.oldindex = P.index
    295                     P.index = P.index + 1
    296                 end
    297             end
    298         end   
    299 
    300     --key left
    301     elseif code == "203" then
    302         if P.index < 0 then
    303             P.index = 0
    304             P.oldindex = -1
    305         elseif P.index % m == 0 then         -- we are at the left-end of a row
    306             P.oldindex = P.index
    307             P.index = P.index +m-1
    308 
    309             while list[P.index+1] == nil do
    310                 P.oldindex = P.index
    311                 P.index = P.index -1
    312             end
    313         else
    314             P.oldindex = P.index
    315             P.index = P.index -1
    316 
    317             while list[P.index+1] == nil do
    318                 if P.index % m == 0 then     -- we are at the left-end of a row
    319                     P.oldindex = P.index
    320                     P.index = P.index -1 + m
    321                 else               
    322                     P.oldindex = P.index
    323                     P.index = P.index -1
    324                 end
    325             end   
    326         end
    327     end   
    328 
    329     cout(0, P.oldindex)
    330     cout(0, P.index)
    331 
    332 end
    333 
    334 
    335 
    336 
  • code/trunk/data/gui/scripts/GraphicsMenu.lua

    r7801 r8079  
    33local P = createMenuSheet("GraphicsMenu")
    44
    5 P.buttonList = {}
     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"}
    66P.schemeList = {"TaharezGreen", "Orxonox"}
    7 
    8 function P.onShow()
    9     --indices to iterate through buttonlist (trivial in this menu sheet)
    10     P.oldindex = -2
    11     P.index = -1
    12 end
    13 
    14 function P.onLoad()
    15     block = true
    16     file = orxonox.PathConfig:getConfigPathString() .. orxonox.getConfig("GraphicsManager", "ogreConfigFile_")
    17     search_mode = 0
    18     f = io.open(file, "r")
    19     firstline = f:read("*line")
    20     rendersystem = string.sub(firstline, 15)
    21     for line in f:lines() do
    22         if search_mode == 0 then
    23             if string.find(line, rendersystem) ~= nil then
    24                 search_mode = 1
    25             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))
    26144        end
    27         if search_mode == 1 then
    28             if string.sub(line, 1, 11) == "Full Screen" then
    29                 if string.sub(line, 13) == "Yes" then
    30                     fullscreen = true
    31                 else
    32                     fullscreen = false
    33                 end
    34             end
    35             if string.sub(line, 1, 10) == "Video Mode" then
    36                 if string.match(line, "@") == "@" then
    37                     resolution = string.sub(line, 12, string.find(line, "@")-2)
    38                 else
    39                     resolution = string.sub(line, 12)
    40                 end
    41                 break
    42             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()
    43225        end
    44226    end
    45     f:close()
    46     local fullscreenwindow = tolua.cast(winMgr:getWindow("orxonox/FullscreenCheckbox"),"CEGUI::Checkbox")
    47     fullscreenwindow:setSelected(fullscreen)
    48     listboxwindow = winMgr:getWindow("orxonox/ResolutionListbox")
    49     local resolutionList = {}
    50     table.insert(resolutionList, "640 x 480")
    51     table.insert(resolutionList, "720 x 480")
    52     table.insert(resolutionList, "720 x 576")
    53     table.insert(resolutionList, "800 x 480")
    54     table.insert(resolutionList, "800 x 600")
    55     table.insert(resolutionList, "1024 x 480")
    56     table.insert(resolutionList, "1024 x 600")
    57     table.insert(resolutionList, "1024 x 768")
    58     table.insert(resolutionList, "1152 x 864")
    59     table.insert(resolutionList, "1280 x 720")
    60     table.insert(resolutionList, "1280 x 768")
    61     table.insert(resolutionList, "1440 x 900")
    62     for k,v in pairs(resolutionList) do
    63         item = CEGUI.createListboxTextItem(v)
    64         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    65         CEGUI.toListbox(listboxwindow):addItem(item)
    66     end
    67     if resolution == "640 x 480" then
    68         listboxwindow:setItemSelectState(0,true)
    69     elseif resolution == "720 x 480" then
    70         listboxwindow:setItemSelectState(1,true)
    71     elseif resolution == "720 x 576" then
    72         listboxwindow:setItemSelectState(2,true)
    73     elseif resolution == "800 x 480" then
    74         listboxwindow:setItemSelectState(3,true)
    75     elseif resolution == "800 x 600" then
    76         listboxwindow:setItemSelectState(4,true)
    77     elseif resolution == "1024 x 480" then
    78         listboxwindow:setItemSelectState(5,true)
    79     elseif resolution == "1024 x 600" then
    80         listboxwindow:setItemSelectState(6,true)
    81     elseif resolution == "1024 x 768" then
    82         listboxwindow:setItemSelectState(7,true)
    83     elseif resolution == "1152 x 864" then
    84         listboxwindow:setItemSelectState(8,true)
    85     elseif resolution == "1280 x 720" then
    86         listboxwindow:setItemSelectState(9,true)
    87     elseif resolution == "1280 x 768" then
    88         listboxwindow:setItemSelectState(10,true)
    89     elseif resolution == "1440 x 900" then
    90         listboxwindow:setItemSelectState(11,true)
    91     end
    92     scrollbar_active = false
    93     block = false
    94 
    95     local item = {
    96             ["button"] = winMgr:getWindow("orxonox/GraphicsBackButton"),
    97             ["function"]  = P.GraphicsBackButton_clicked
    98     }
    99     P.buttonList[1] = item
    100 
    101     local dropbox = winMgr:getWindow("orxonox/ThemeDropBox")
    102     local scheme = orxonox.CommandExecutor:query("getConfig GUIManager guiScheme_")
    103     for k,v in pairs(P.schemeList) do
    104         local item = CEGUI.createListboxTextItem(P.schemeList[k])
    105         item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    106         CEGUI.toListbox(dropbox):addItem(item)
    107         if v == scheme then
    108             dropbox:setItemSelectState(item, true)
    109         end
    110     end
    111 
    112 end
    113 
    114 function P.ThemeDropBox_changed(e)
    115     local dropbox = winMgr:getWindow("orxonox/ThemeDropBox")
    116     local listbox = CEGUI.toListbox(dropbox)
    117     local choice = listbox:getFirstSelectedItem()
    118     local index = 0
    119     if choice ~= nil then
    120         index = listbox:getItemIndex(choice)
    121     end
    122     orxonox.CommandExecutor:execute("config GUIManager guiScheme_ " .. P.schemeList[index+1])
    123 end
    124 
    125 function P.GraphicsResolutionListbox_changed(e)
    126     if listboxwindow:isItemSelected(0) then
    127         resolution = "640 x 480"
    128     elseif listboxwindow:isItemSelected(1) then
    129         resolution = "720 x 480"
    130     elseif listboxwindow:isItemSelected(2) then
    131         resolution = "720 x 576"
    132     elseif listboxwindow:isItemSelected(3) then
    133         resolution = "800 x 480"
    134     elseif listboxwindow:isItemSelected(4) then
    135         resolution = "800 x 600"
    136     elseif listboxwindow:isItemSelected(5) then
    137         resolution = "1024 x 480"
    138     elseif listboxwindow:isItemSelected(6) then
    139         resolution = "1024 x 600"
    140     elseif listboxwindow:isItemSelected(7) then
    141         resolution = "1024 x 768"
    142     elseif listboxwindow:isItemSelected(8) then
    143         resolution = "1152 x 864"
    144     elseif listboxwindow:isItemSelected(9) then
    145         resolution = "1280 x 720"
    146     elseif listboxwindow:isItemSelected(10) then
    147         resolution = "1280 x 768"
    148     elseif listboxwindow:isItemSelected(11) then
    149         resolution = "1440 x 900"
    150     end
    151     search_mode = 0
    152     f = io.open(file, "r")
    153     firstline = f:read("*line")
    154     text = firstline .. "\n"
    155     rendersystem = string.sub(firstline, 15)
    156     for line in f:lines() do
    157         if search_mode == 0 then
    158             if string.find(line, rendersystem) ~= nil then
    159                 search_mode = 1
    160             end
    161         end
    162         if search_mode == 1 then
    163             if string.sub(line, 1, 10) == "Video Mode" then
    164                 if string.match(line, "@") == "@" then
    165                     line = "Video Mode=" .. resolution .. string.sub(line, string.find(line, "@")-1)
    166                 else
    167                     line = "Video Mode=" .. resolution
    168                 end
    169                 search_mode = 2
    170             end
    171         end
    172         text = text .. line .. "\n"
    173     end
    174     f:close()
    175     f = io.open(file, "w")
    176     f:write(text)
    177     f:close()
    178 end
    179 
    180 function P.GraphicsBrightnessScrollbar_changed(e)
    181     if scrollbar_active == false then
    182         -- brightness
    183         logMessage(0, "event: brightness")
    184     end
    185 end
    186 
    187 function P.GraphicsBrightnessScrollbar_started(e)
    188     scrollbar_active = true
    189 end
    190 
    191 function P.GraphicsBrightnessScrollbar_ended(e)
    192     -- brightness
    193     logMessage(0, "event: brightness")
    194     scrollbar_active = false
    195 end
    196 
    197 function P.GraphicsFullscreenCheckbox_clicked(e)
    198     if block == false then
    199         search_mode = 0
    200         f = io.open(file, "r")
    201         firstline = f:read("*line")
    202         text = firstline .. "\n"
    203         rendersystem = string.sub(firstline, 15)
    204         for line in f:lines() do
    205             if search_mode == 0 then
    206                 if string.find(line, rendersystem) ~= nil then
    207                     search_mode = 1
    208                 end
    209             end
    210             if search_mode == 1 then
    211                 if string.sub(line, 1, 11) == "Full Screen" then
    212                     if fullscreen == true then
    213                         line = "Full Screen=No"
    214                         fullscreen = false
    215                     else
    216                         line = "Full Screen=Yes"
    217                         fullscreen = true
    218                     end
    219                     search_mode = 2
    220                 end
    221             end
    222             text = text .. line .. "\n"
    223         end
    224         f:close()
    225         f = io.open(file, "w")
    226         f:write(text)
    227         f:close()
    228     end
    229 end
    230 
    231 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
    232413    hideMenuSheet(P.name)
    233414end
    234415
    235 function P.onKeyPressed()
    236     buttonIteratorHelper(P.buttonList, code, P, 1, 1)
     416function P.callback_Cancel_Clicked(e)
     417    hideMenuSheet(P.name)
    237418end
    238419
  • code/trunk/data/gui/scripts/HostMenu.lua

    r7887 r8079  
    55P.multiplayerMode = "startServer"
    66
    7 P.buttonList = {}
    87P.levelList = {}
    98P.itemList = {}
     
    1110
    1211function P.onLoad()
    13     P.multiplayerMode = "startServer" 
     12    P.multiplayerMode = "startServer"
    1413    local window = winMgr:getWindow("orxonox/MultiplayerShowAllCheckbox")
    1514    local button = tolua.cast(window,"CEGUI::Checkbox")
     
    1716    P.createLevelList()
    1817
    19     local item = {
     18    P:setButton(1, 1, {
    2019            ["button"] = winMgr:getWindow("orxonox/HostMenuStartButton"),
    21             ["function"]  = P.HostMenuStartButton_clicked
    22     }
    23     P.buttonList[1] = item
     20            ["callback"]  = P.HostMenuStartButton_clicked
     21    })
    2422
    25     local item = {
     23    P:setButton(1, 2, {
    2624            ["button"] = winMgr:getWindow("orxonox/HostMenuBackButton"),
    27             ["function"]  = P.HostMenuBackButton_clicked
    28     }
    29     P.buttonList[2] = item
     25            ["callback"]  = P.HostMenuBackButton_clicked
     26    })
    3027end
    3128
    3229function 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
    3337    if P.multiplayerMode == "startServer" then
    3438        local window = winMgr:getWindow("orxonox/HostMenuHostButton")
     
    4448        P.createLevelList()
    4549    end
    46 
    47     P.oldindex = -2
    48     P.index = -1
    49 
    5050end
    5151
     
    9797end
    9898
    99 function P.HostMenuStartButton_clicked(e)   
     99function P.HostMenuStartButton_clicked(e)
    100100    local listbox = CEGUI.toListbox(winMgr:getWindow("orxonox/HostMenuListbox"))
    101101    local choice = listbox:getFirstSelectedItem()
     
    119119end
    120120
    121 function P.onKeyPressed()
    122     buttonIteratorHelper(P.buttonList, code, P, 1, 2)
    123 end
    124 
    125121return P
  • code/trunk/data/gui/scripts/InGameMenu.lua

    r7877 r8079  
    44P.loadAlong = { "DecisionPopup" }
    55
    6 P.buttonList = {}
    7 
    86function P.onLoad()
    9     P.multiplayerMode = "startClient" 
     7    P.multiplayerMode = "startClient"
    108
    119    --button are arranged in a 4x1 matrix, the left lower item is nil
    12     local item = {
     10    P:setButton(1, 1, {
    1311            ["button"] = winMgr:getWindow("orxonox/InGameMenu_ReturnButton"),
    14             ["function"]  = P.button_settings_clicked
    15     }
    16     P.buttonList[1] = item
     12            ["callback"]  = P.button_return_clicked
     13    })
    1714
    18     local item = {
     15    P:setButton(2, 1, {
    1916            ["button"] = winMgr:getWindow("orxonox/InGameMenu_MainMenuButton"),
    20             ["function"]  = P.button_mainmenu_clicked
    21     }
    22     P.buttonList[2] = item
     17            ["callback"]  = P.button_mainmenu_clicked
     18    })
    2319
    24     local item = {
     20    P:setButton(3, 1, {
    2521            ["button"] = winMgr:getWindow("orxonox/InGameMenu_SettingsButton"),
    26             ["function"]  = P.button_settings_clicked
    27     }
    28     P.buttonList[3] = item
     22            ["callback"]  = P.button_settings_clicked
     23    })
    2924
    30     local item = {
     25    P:setButton(4, 1, {
    3126            ["button"] = winMgr:getWindow("orxonox/InGameMenu_QuitButton"),
    32             ["function"]  = P.button_quit_clicked
    33     }
    34     P.buttonList[4] = item
    35 
     27            ["callback"]  = P.button_quit_clicked
     28    })
    3629end
    3730
    3831function P.onShow()
    39     --indices to iterate through buttonlist
    40     P.oldindex = -2
    41     P.index = -1
     32    if P:hasSelection() == false then
     33        P:setSelection(1, 1)
     34    end
     35
     36    orxonox.execute("setPause 1")
     37end
     38
     39function P.onQuit()
     40    orxonox.execute("setPause 0")
    4241end
    4342
     
    6463        hideMenuSheet("InGameMenu")
    6564        orxonox.execute("exit")
    66     else 
     65    else
    6766        P.onShow()
    6867    end
    6968end
    7069
    71 function P.onKeyPressed()
    72     buttonIteratorHelper(P.buttonList, code, P, 4, 1)
    73 end
    74 
    7570return P
    7671
  • code/trunk/data/gui/scripts/KeyBindMenu.lua

    r7403 r8079  
    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")
     
    3535    table.insert(commandList, "mouseLook")
    3636    table.insert(commandList, "pause")
     37    table.insert(commandList, "printScreen")
     38    if orxonox.GUIManager:inDevMode() then
     39        table.insert(commandList, "printScreenHD 3")
     40    end
    3741
    3842    nameList = {}
     
    6569    table.insert(nameList, "Look Around")
    6670    table.insert(nameList, "Pause")
     71    table.insert(nameList, "Screenshot")
     72    if orxonox.GUIManager:inDevMode() then
     73        table.insert(nameList, "HD screenshot")
     74    end
    6775
    6876    linesList = {}
     
    100108    local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
    101109    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
     110
     111    P:setButton(1, 1, {
     112            ["button"] = winMgr:getWindow("orxonox/KeyBindBackButton"),
     113            ["callback"]  = P.KeyBindBackButton_clicked
     114    })
    102115end
    103116
  • code/trunk/data/gui/scripts/MainMenu.lua

    r7689 r8079  
    44P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" }
    55
    6 P.buttonList = {}
    7 
    86function P.onLoad()
    97    --buttons are arranged in a 6x1 Matrix (list)
    10     local item = {
     8    P:setButton(1, 1, {
    119            ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"),
    12             ["function"]  = P.QuickGameTestButton_clicked
    13     }
    14     table.insert(P.buttonList,item)
     10            ["callback"]  = P.QuickGameTestButton_clicked
     11    })
    1512
    16     item = {
     13    P:setButton(2, 1, {
    1714            ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"),
    18             ["function"]  = P.SingleplayerButton_clicked
    19     }
    20     table.insert(P.buttonList,item)
     15            ["callback"]  = P.SingleplayerButton_clicked
     16    })
    2117
    22     item = {
     18    P:setButton(3, 1, {
    2319            ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"),
    24             ["function"]  = P.MultiplayerButton_clicked
    25     }
    26     table.insert(P.buttonList,item)
     20            ["callback"]  = P.MultiplayerButton_clicked
     21    })
    2722
    28     item = {
     23    P:setButton(4, 1, {
    2924            ["button"] = winMgr:getWindow("orxonox/SettingsButton"),
    30             ["function"]  = P.SettingsButton_clicked
    31     }
    32     table.insert(P.buttonList,item)
     25            ["callback"]  = P.SettingsButton_clicked
     26    })
    3327
    34     item = {
     28    P:setButton(5, 1, {
    3529            ["button"] = winMgr:getWindow("orxonox/CreditsButton"),
    36             ["function"]  = P.CreditsButton_clicked
    37     }
    38     table.insert(P.buttonList,item)
     30            ["callback"]  = P.CreditsButton_clicked
     31    })
    3932
    40     item = {
     33    P:setButton(6, 1, {
    4134            ["button"] = winMgr:getWindow("orxonox/ExitButton"),
    42             ["function"]  = P.ExitButton_clicked
    43     }
    44     table.insert(P.buttonList,item)
    45 end
    46 
    47 function P.onShow()
    48     --indices to iterate through buttonlist
    49     P.oldindex = -2
    50     P.index = -1
     35            ["callback"]  = P.ExitButton_clicked
     36    })
    5137end
    5238
     
    7763end
    7864
    79 function P.onKeyPressed()
    80     buttonIteratorHelper(P.buttonList, code, P, 6, 1)
    81 end
    82 
    8365return P
    8466
  • code/trunk/data/gui/scripts/MiscConfigMenu.lua

    r7403 r8079  
    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 = {}
     
    8587    P.createLines()
    8688
     89    P:setButton(1, 1, {
     90            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
     91            ["callback"]  = P.MiscConfigBackButton_clicked
     92    })
    8793end
    8894
  • code/trunk/data/gui/scripts/MouseControlsMenu.lua

    r6746 r8079  
    3232        invert_active = false
    3333    end
     34
     35    P:setButton(1, 1, {
     36            ["button"] = winMgr:getWindow("orxonox/MouseControlsBackButton"),
     37            ["callback"]  = P.MouseControlsBackButton_clicked
     38    })
    3439end
    3540
  • code/trunk/data/gui/scripts/MultiplayerMenu.lua

    r7876 r8079  
    22
    33local P = createMenuSheet("MultiplayerMenu")
    4 
    5 P.buttonList = {}
    64
    75--joinMode is 1 for choice "LAN" and 2 for "Internet"
     
    108
    119function P.onLoad()
    12     P.multiplayerMode = "startClient" 
     10    P.multiplayerMode = "startClient"
    1311
    14     --button are arranged in a 2x2 matrix, the left lower item is nil
    15     local item = {
     12    --button are arranged in a 3x2 matrix, Join and Host buttons are in the upper left and middle, the back button in the lower right of the table
     13    P:setButton(1, 1, {
    1614            ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton"),
    17             ["function"]  = P.MultiplayerJoinButton_clicked
    18     }
    19     P.buttonList[1] = item
     15            ["callback"]  = P.MultiplayerJoinButton_clicked
     16    })
    2017
    21     local item = {
     18    P:setButton(1, 2, {
    2219            ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton"),
    23             ["function"]  = P.MultiplayerHostButton_clicked
    24     }
    25     P.buttonList[2] = item
     20            ["callback"]  = P.MultiplayerHostButton_clicked
     21    })
    2622
    27     local item = {
     23    P:setButton(2, 3, {
    2824            ["button"] = winMgr:getWindow("orxonox/MultiplayerBackButton"),
    29             ["function"]  = P.MultiplayerBackButton_clicked
    30     }
    31     P.buttonList[4] = item
     25            ["callback"]  = P.MultiplayerBackButton_clicked
     26    })
    3227end
    3328
     
    3530    --P.showServerList()
    3631
    37     --indices to iterate through buttonlist
    38     P.oldindex = -2
    39     P.index = -1
    40    
    4132    if P.joinMode == 1 then
    4233        local window = winMgr:getWindow("orxonox/MultiplayerLanButton")
     
    5647    P.joinMode = 1
    5748    if button:isSelected() == true then
    58             P.showServerList()
     49        P.showServerList()
    5950    end
    6051end
     
    6556    P.joinMode = 2
    6657    if button:isSelected() == true then
    67             P.showServerList()
    68         end
     58        P.showServerList()
     59    end
    6960end
    7061
     
    9283
    9384function P.showServerList()
    94         -- LAN Discovery
    95         if P.joinMode == 1 then
    96                 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
    97                 CEGUI.toListbox(listbox):resetList()
    98                 local discovery = orxonox.LANDiscovery:getInstance()
    99                 discovery:discover()
    100                 P.serverList = {}
    101                 local index = 0
    102                 local servername = ""
    103                 local serverip = ""
    104                 while true do
    105                     servername = discovery:getServerListItemName(index)
    106                     if servername == "" then
    107                         break
    108                     end
    109                     serverip = discovery:getServerListItemIP(index)
    110                     if serverip == "" then
    111                       break
    112                     end
    113                     table.insert(P.serverList, {servername, serverip})
    114                     index = index + 1
    115                 end
    116                 index = 1
    117                 for k,v in pairs(P.serverList) do
    118                     local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] )
    119                     item:setID(index)
    120                     index = index + 1
    121                     item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    122                     CEGUI.toListbox(listbox):addItem(item)
    123                 end
    124         -- WAN Discovery
    125         elseif P.joinMode == 2 then
    126                 local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
    127                 CEGUI.toListbox(listbox):resetList()
    128                 local discovery = orxonox.WANDiscovery:getInstance()
    129                 cout(0, "discovering.\n" )
    130                 discovery:discover()
    131                 cout(0, "discovered.\n" )
    132                 P.serverList = {}
    133                 local index = 0
    134                 local servername = ""
    135                 local serverip = ""
    136                 while true do
    137                     servername = discovery:getServerListItemName(index)
    138                     if servername == "" then
    139                         break
    140                     end
    141                     serverip = discovery:getServerListItemIP(index)
    142                     if serverip == "" then
    143                       break
    144                     end
    145                     table.insert(P.serverList, {servername, serverip})
    146                     index = index + 1
    147                 end
    148                 index = 1
    149                 for k,v in pairs(P.serverList) do
    150                     local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] )
    151                     item:setID(index)
    152                     index = index + 1
    153                     item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
    154                     CEGUI.toListbox(listbox):addItem(item)
    155                 end
    156         end
    157        
    158 end
     85    -- LAN Discovery
     86    if P.joinMode == 1 then
     87        local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
     88        CEGUI.toListbox(listbox):resetList()
     89        local discovery = orxonox.LANDiscovery:getInstance()
     90        discovery:discover()
     91        P.serverList = {}
     92        local index = 0
     93        local servername = ""
     94        local serverip = ""
     95        while true do
     96            servername = discovery:getServerListItemName(index)
     97            if servername == "" then
     98                break
     99            end
     100            serverip = discovery:getServerListItemIP(index)
     101            if serverip == "" then
     102                break
     103            end
     104            table.insert(P.serverList, {servername, serverip})
     105            index = index + 1
     106        end
     107        index = 1
     108        for k,v in pairs(P.serverList) do
     109            local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] )
     110            item:setID(index)
     111            index = index + 1
     112            item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     113            CEGUI.toListbox(listbox):addItem(item)
     114        end
     115    -- WAN Discovery
     116    elseif P.joinMode == 2 then
     117        local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
     118        CEGUI.toListbox(listbox):resetList()
     119        local discovery = orxonox.WANDiscovery:getInstance()
     120        cout(0, "discovering.\n" )
     121        discovery:discover()
     122        cout(0, "discovered.\n" )
     123        P.serverList = {}
     124        local index = 0
     125        local servername = ""
     126        local serverip = ""
     127        while true do
     128            servername = discovery:getServerListItemName(index)
     129            if servername == "" then
     130                break
     131            end
     132            serverip = discovery:getServerListItemIP(index)
     133            if serverip == "" then
     134                break
     135            end
     136            table.insert(P.serverList, {servername, serverip})
     137            index = index + 1
     138        end
     139        index = 1
     140        for k,v in pairs(P.serverList) do
     141            local item = CEGUI.createListboxTextItem( v[1] .. ": " .. v[2] )
     142            item:setID(index)
     143            index = index + 1
     144            item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
     145            CEGUI.toListbox(listbox):addItem(item)
     146        end
     147    end
    159148
    160 function P.onKeyPressed()
    161     buttonIteratorHelper(P.buttonList, code, P, 2, 2)
    162149end
    163150
  • code/trunk/data/gui/scripts/NotificationLayer.lua

    r7887 r8079  
    4646end
    4747
    48 -- Pushes an input notification to the input queue. 
     48-- Pushes an input notification to the input queue.
    4949function P.pushNotification(queueName, notification)
    5050    local queue = P.queueList[queueName]
     
    333333
    334334-- Is called after the sheet has been hidden.
    335 function P.afterHide()
     335function P.onQuit()
    336336    -- If we leave the edit mode we show the sheet again.
    337337    if P.editMode then
  • code/trunk/data/gui/scripts/SettingsMenu.lua

    r7689 r8079  
    44P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" }
    55
    6 P.buttonList = {}
    7 
    86function P.onLoad()
    97    --"Gameplay" and "Multiplayer Options" are not integrated in the list
    10     --buttons are arranged in a 4x2 matrix. The lower-right element is not in the matrix!
    11     local item = {
     8    --buttons are arranged in a 4x2 matrix.
     9    P:setButton(1, 2, {
    1210            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"),
    13             ["function"]  = P.SettingsGraphicsButton_clicked
    14     }
    15     P.buttonList[2] = item
     11            ["callback"]  = P.SettingsGraphicsButton_clicked
     12    })
    1613
    17     local item = {
     14    P:setButton(2, 2, {
    1815            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"),
    19             ["function"]  = P.SettingsAudioButton_clicked
    20     }
    21     P.buttonList[4] = item
     16            ["callback"]  = P.SettingsAudioButton_clicked
     17    })
    2218
     19    P:setButton(3, 1, {
     20            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
     21            ["callback"]  = P.SettingsControlsButton_clicked
     22    })
    2323
    24     local item = {
    25             ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"),
    26             ["function"]  = P.SettingsControlsButton_clicked
    27     }
    28     P.buttonList[5] = item
     24    P:setButton(3, 2, {
     25            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
     26            ["callback"]  = P.SettingsMiscellaneousButton_clicked
     27    })
    2928
    30     local item = {
    31             ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"),
    32             ["function"]  = P.SettingsMiscellaneousButton_clicked
    33     }
    34     P.buttonList[6] = item
     29    P:setButton(4, 1, {
     30            ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"),
     31            ["callback"]  = P.SettingsBackButton_clicked
     32    })
    3533
    36     local item = {
    37             ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"),
    38             ["function"]  = P.SettingsBackButton_clicked
    39     }
    40     P.buttonList[7] = item
    41 
    42 end
    43 
    44 function P.onShow()
    45     --indices to iterate through buttonlist
    46     P.oldindex = 3
    47     P.index = 2
     34    P:setButton(4, 2, P:getButton(4, 1))
    4835end
    4936
     
    7663end
    7764
    78 function P.onKeyPressed()
    79     buttonIteratorHelper(P.buttonList, code, P, 4, 2)
    80 end
    81 
    8265return P
    8366
  • code/trunk/data/gui/scripts/SheetManager.lua

    r7689 r8079  
    88local mainMenuLoaded = false
    99orxonox.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 
     10orxonox.GUIManager:subscribeEventHelper(menuSheetsRoot, "Sized", "windowResized")
    2711
    2812------------------------
    2913--- Global functions ---
    3014------------------------
     15
     16function hideCursor()
     17    if cursor:isVisible() then
     18        cursor:hide()
     19    end
     20end
     21
     22function showCursor()
     23    if not cursor:isVisible() and inputMgr:isMouseExclusive() then
     24        cursor:show()
     25    end
     26end
    3127
    3228-- Loads the GUI with the specified name
     
    9389        ["sheet"]          = menuSheet,
    9490        ["bHidePrevious"]  = bHidePrevious,
    95         ["bNoInput"]       = bNoInput
     91        ["bNoInput"]       = bNoInput,
     92        ["name"]           = name
    9693    }
    9794    table.insert(activeMenuSheets, sheetTuple) -- indexed array access
     
    121118
    122119    -- Hide all previous sheets if necessary
     120    local previous
    123121    if bHidePrevious then
    124122        for i = 1, activeMenuSheets.size - 1 do
    125             activeMenuSheets[i].sheet:hide()
    126         end
    127     end
    128    
     123            previous = activeMenuSheets[i].sheet
     124            previous:hide()
     125        end
     126    end
     127
    129128    menuSheet:show()
    130129    menuSheetsRoot:activate()
     130
     131    -- select first button if the menu was opened with the keyboard
     132    if previous and previous.pressedEnter and menuSheet:hasSelection() == false then
     133        menuSheet:setSelectionNear(1, 1)
     134    end
    131135
    132136    return menuSheet
     
    179183        inputMgr:leaveState(sheetTuple.sheet.inputState)
    180184    end
    181    
     185
    182186    -- CURSOR SHOWING
    183187    local i = activeMenuSheets.size
     
    200204    end
    201205
    202     sheetTuple.sheet:afterHide()
     206    sheetTuple.sheet:quit()
    203207end
    204208
     
    242246            keyESC()
    243247        elseif code == "0"then
    244             orxonox.CommandExecutor:execute("openConsole")
    245         end
    246     end
    247     sheet.sheet:onKeyPressed()
     248            orxonox.CommandExecutor:execute("InGameConsole openConsole")
     249        end
     250    end
     251    sheet.sheet:keyPressed()
     252end
     253
     254function windowResized(e)
     255    for name, sheet in pairs(loadedSheets) do
     256        if orxonox.GraphicsManager:getInstance():isFullScreen() or sheet.tShowCursor == TriBool.False then
     257            inputMgr:setMouseExclusive(sheet.inputState, TriBool.True)
     258        else
     259            inputMgr:setMouseExclusive(sheet.inputState, TriBool.False)
     260        end
     261    end
     262    local sheetTuple = activeMenuSheets[activeMenuSheets.size]
     263    if sheetTuple then
     264        if orxonox.GraphicsManager:getInstance():isFullScreen() and sheetTuple.sheet.tShowCursor ~= TriBool.False then
     265            showCursor()
     266        else
     267            hideCursor()
     268        end
     269        sheetTuple.sheet:windowResized()
     270    end
    248271end
    249272
     
    276299end
    277300
     301function getGUIFirstActive(name, bHidePrevious, bNoInput)
     302    local sheet = activeMenuSheets.topSheetTuple
     303    -- If the topmost gui sheet has the input name
     304    if sheet ~= nil and sheet.name == name then
     305        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, false);
     306    else
     307        guiMgr:toggleGUIHelper(name, bHidePrevious, bNoInput, true);
     308    end
     309end
     310
    278311----------------------
    279312--- Initialisation ---
  • code/trunk/data/gui/scripts/SingleplayerMenu.lua

    r7876 r8079  
    33local P = createMenuSheet("SingleplayerMenu")
    44
    5 P.buttonList = {}
    65P.levelList = {}
    76P.itemList = {}
     
    1514
    1615    --buttons are arranged in a 1x2 matrix
    17     local item = {
     16    P:setButton(1, 1, {
    1817            ["button"] = winMgr:getWindow("orxonox/SingleplayerStartButton"),
    19             ["function"]  = P.SingleplayerStartButton_clicked
    20     }
    21     P.buttonList[1] = item
     18            ["callback"]  = P.SingleplayerStartButton_clicked
     19    })
    2220
    23     local item = {
     21    P:setButton(1, 2, {
    2422            ["button"] = winMgr:getWindow("orxonox/SingleplayerBackButton"),
    25             ["function"]  = P.SingleplayerBackButton_clicked
    26     }
    27     P.buttonList[2] = item
     23            ["callback"]  = P.SingleplayerBackButton_clicked
     24    })
     25end
     26
     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
    2835end
    2936
     
    4754        index = index + 1
    4855    end
    49     --TODO: Reintroduce sorting, if needed. At the moment it's sorted by filename.
    50     --table.sort(levelList)
    5156    for k,v in pairs(P.levelList) do
    5257        local item = CEGUI.createListboxTextItem(v:getName())
     
    5964        orxonox.GUIManager:setTooltipTextHelper(P.itemList[k], v:getDescription())
    6065    end
    61 end
    62 
    63 function P.onShow()
    64     --indices to iterate through buttonlist
    65     P.oldindex = -2
    66     P.index = -1
    6766end
    6867
     
    9392end
    9493
    95 function P.onKeyPressed()
    96     buttonIteratorHelper(P.buttonList, code, P, 1, 2)
    97 end
    98 
    9994return P
    10095
  • code/trunk/data/levels/FPSTest.oxw

    r7679 r8079  
    5757  <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 100) ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>" >
    5858      <attached>
    59         <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     59        <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    6060      </attached>
    6161      <collisionShapes>
  • code/trunk/data/levels/asteroids.oxw

    r8009 r8079  
    3535      linearDamping = 0.8
    3636      angularDamping = 0
    37       scale = <?lua print(j * 150)?>
     37      scale = "<?lua print(j * 150)?>"
    3838      collisiondamage = 1
    3939      enablecollisiondamage = true
    4040    >
    4141      <attached>
    42         <Model mass=<?lua print(j * 1000) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     42        <Model mass="<?lua print(j * 1000) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    4343      </attached>
    4444      <collisionShapes>
  • code/trunk/data/levels/dynamicMatch.oxw

    r7679 r8079  
    8080?>
    8181
    82     <StaticEntity position="<?lua print(x + math.random() * 1000-500) ?>,<?lua print(y + math.random() * 1000-500) ?>,<?lua print(z + math.random() * 5000-2500) ?>" scale=<?lua print(j * 5) ?> >
     82    <StaticEntity position="<?lua print(x + math.random() * 1000-500) ?>,<?lua print(y + math.random() * 1000-500) ?>,<?lua print(z + math.random() * 5000-2500) ?>" scale="<?lua print(j * 5) ?>" >
    8383      <attached>
    84         <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
     84        <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
    8585          <attached><!-- ---------asteroid fog----- -->
    8686            <ParticleEmitter position="0,0,0" source="Orxonox/Steam" />
  • code/trunk/data/levels/fightInOurBack.oxw

    r7845 r8079  
    172172    <events>
    173173    <trigger>
    174         <SpaceShip position="<?lua print(3800-i*x) ?>,0,3000" lookat="<?lua print(4800-i*x) ?>,0,4000" health=<?lua print(health) ?> maxhealth=<?lua print(health) ?> initialhealth=<?lua print(health) ?> >
     174        <SpaceShip position="<?lua print(3800-i*x) ?>,0,3000" lookat="<?lua print(4800-i*x) ?>,0,4000" health="<?lua print(health) ?>" maxhealth="<?lua print(health) ?>" initialhealth="<?lua print(health) ?>" >
    175175            <templates>
    176176                   <Template link=spaceshipTransporter />
     
    199199    <events>
    200200    <trigger>
    201         <SpaceShip position="<?lua print(2600+x) ?>,0,<?lua print(3150-z) ?>" lookat="<?lua print(3500+x) ?>,0,<?lua print(4150-z) ?>" health=<?lua print(health) ?> maxhealth=<?lua print(health) ?> initialhealth=<?lua print(health) ?> >
     201        <SpaceShip position="<?lua print(2600+x) ?>,0,<?lua print(3150-z) ?>" lookat="<?lua print(3500+x) ?>,0,<?lua print(4150-z) ?>" health="<?lua print(health) ?>" maxhealth="<?lua print(health) ?>" initialhealth="<?lua print(health) ?>" >
    202202            <templates>
    203203                   <Template link=spaceshipTransporter />
     
    284284<MovableEntity collisionType=kinematic linearDamping=0.8 angularDamping=0 mass="<?lua print(scale * 5) ?>" position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" rotationaxis="<?lua print(math.random()) ?>,<?lua print(math.random()) ?>,<?lua print(math.random()) ?>" rotationrate="<?lua print(math.random()*15) ?>">
    285285    <attached>
    286         <Model scale=<?lua print(scale) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false/>
     286        <Model scale="<?lua print(scale) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false/>
    287287    </attached>
    288288    <collisionShapes>
     
    303303<MovableEntity collisionType=kinematic linearDamping=0.8 angularDamping=0 mass="<?lua print(scale * 5) ?>" position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" rotationaxis="<?lua print(math.random()) ?>,<?lua print(math.random()) ?>,<?lua print(math.random()) ?>" rotationrate="<?lua print(math.random()*15) ?>" >
    304304    <attached>
    305         <Model scale=<?lua print(math.random(20,70)) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false/>
     305        <Model scale="<?lua print(math.random(20,70)) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" shadow=false/>
    306306    </attached>
    307307    <collisionShapes>
  • code/trunk/data/levels/lastManStanding.oxw

    r7785 r8079  
    7676    <SpawnPoint team=0 position="<?lua print(y*1.4+z*0.2) ?>,0,<?lua print(z*1.4-y*0.2) ?>" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    7777
    78     <StaticEntity position="<?lua print(y) ?>,0,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     78    <StaticEntity position="<?lua print(y) ?>,0,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
    7979      <attached>
    8080        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh">
     
    8686    </StaticEntity>
    8787
    88     <StaticEntity position="<?lua print(y) ?>,100,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     88    <StaticEntity position="<?lua print(y) ?>,100,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
    8989      <attached>
    9090        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i+3,6) + 1) ?>.mesh">
     
    9696    </StaticEntity>
    9797
    98     <StaticEntity position="<?lua print(y) ?>,200,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     98    <StaticEntity position="<?lua print(y) ?>,200,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
    9999      <attached>
    100100        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i*5,6) + 1) ?>.mesh">
     
    106106    </StaticEntity>
    107107
    108     <StaticEntity position="<?lua print(y) ?>,-100,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     108    <StaticEntity position="<?lua print(y) ?>,-100,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
    109109      <attached>
    110110        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i*13+1,6) + 1) ?>.mesh">
     
    116116    </StaticEntity>
    117117
    118     <StaticEntity position="<?lua print(y) ?>,-200,<?lua print(z) ?>" scale=<?lua print(j * 2) ?> collisionType=static >
     118    <StaticEntity position="<?lua print(y) ?>,-200,<?lua print(z) ?>" scale="<?lua print(j * 2) ?>" collisionType=static >
    119119      <attached>
    120120        <Model position="0,0,0" scale=15 mesh="ast<?lua print( math.mod(i*17,6) + 1) ?>.mesh">
     
    127127
    128128<!-- ---------Top Asteroid----------- -->
    129     <StaticEntity position="<?lua print(y) ?>,300,<?lua print(z) ?>" scale=<?lua print(j * 2.1) ?> pitch="90" roll="180" yaw="<?lua print(-90+i*360/max) ?>" collisionType=static >
     129    <StaticEntity position="<?lua print(y) ?>,300,<?lua print(z) ?>" scale="<?lua print(j * 2.1) ?>" pitch="90" roll="180" yaw="<?lua print(-90+i*360/max) ?>" collisionType=static >
    130130      <attached>
    131131        <Model position="0,0,0" scale=25 mesh="ast6.mesh">
  • code/trunk/data/levels/presentation09.oxw

    r7679 r8079  
    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/>
     
    4747      ?>
    4848
    49       <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
     49      <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass="<?lua print(j * 50) ?>" <?lua end ?> scale="<?lua print(j * 5) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    5050        <attached>
    51           <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     51          <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    5252        </attached>
    5353        <?lua if i == 5 then ?><collisionShapes>
  • code/trunk/data/levels/presentation09b.oxw

    r7679 r8079  
    281281            material="Examples/Flare"
    282282            colour="1.0, 0.5, 0.3"
    283             phase=<?lua print(-360/8*i)?>
     283            phase="<?lua print(-360/8*i)?>"
    284284            amplitude=0.1
    285285            frequency=0.5
     
    291291            material="Examples/Flare"
    292292            colour="1.0, 0.5, 0.3"
    293             phase=<?lua print(-360/8*i)?>
     293            phase="<?lua print(-360/8*i)?>"
    294294            amplitude=0.1
    295295            frequency=0.5
     
    357357      <MovableEntity position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 - 15) ?>">
    358358        <attached>
    359           <Model position="0,0,0" scale=<?lua print(s) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     359          <Model position="0,0,0" scale="<?lua print(s) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    360360        </attached>
    361361      </MovableEntity>
  • code/trunk/data/levels/presentationDM.oxw

    r7679 r8079  
    4646        j = math.random()
    4747    ?>
    48       <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
     48      <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass="<?lua print(j * 50) ?>" scale="<?lua print(j * 5) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    4949        <attached>
    50           <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     50          <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    5151        </attached>
    5252        <collisionShapes>
  • code/trunk/data/levels/presentationFS102.oxw

    r7679 r8079  
    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/trunk/data/levels/presentationFS10Ed.oxw

    r7679 r8079  
    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/trunk/data/levels/presentationHS09.oxw

    r7679 r8079  
    11<LevelInfo
    2  name = "Presentation X"
     2 name = "Presentation X 1st"
    33 description = "1st Presentation level for Orxonox Convention X"
    44 tags = "presentation"
     
    193193        </templates>
    194194        <controller>
    195           <WaypointPatrolController name=attacker alertnessradius=<?lua print(math.random() * 2000) ?> team=0 active=false>
     195          <WaypointPatrolController name=attacker alertnessradius="<?lua print(math.random() * 2000) ?>" team=0 active=false>
    196196            <waypoints>
    197197              <StaticEntity position="<?lua print(2800 + math.random() * 500 - 250) ?>,<?lua print(2500 + math.random() * 500 - 250) ?>,<?lua print(1500 + math.random() * 500 - 250) ?>" />
     
    284284            material="Examples/Flare"
    285285            colour="1.0, 0.5, 0.3"
    286             phase=<?lua print(-360/8*i)?>
     286            phase="<?lua print(-360/8*i)?>"
    287287            amplitude=0.1
    288288            frequency=0.5
     
    294294            material="Examples/Flare"
    295295            colour="1.0, 0.5, 0.3"
    296             phase=<?lua print(-360/8*i)?>
     296            phase="<?lua print(-360/8*i)?>"
    297297            amplitude=0.1
    298298            frequency=0.5
     
    368368      <MovableEntity mass=90000 position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.8 angularDamping=0.8 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
    369369        <attached>
    370           <Model position="0,0,0" scale=<?lua print(s) ?> mesh="<?lua print(elements[e])?>" />
     370          <Model position="0,0,0" scale="<?lua print(s) ?>" mesh="<?lua print(elements[e])?>" />
    371371        </attached>
    372372      </MovableEntity>
  • code/trunk/data/levels/presentationHS09b.oxw

    r7854 r8079  
    11<LevelInfo
    2  name = "Presentation X"
     2 name = "Presentation X 2nd"
    33 description = "2nd Presentation level for Orxonox Convention X"
    44 tags = "presentation"
     
    4646        s = math.random() * 100
    4747    ?>
    48       <MovableEntity collisiontype=dynamic mass=<?lua print(s*10)?> position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.01 angularDamping=0 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
     48      <MovableEntity collisiontype=dynamic mass="<?lua print(s*10)?>" position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.01 angularDamping=0 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
    4949        <attached>
    50           <Model position="0,0,0" scale=<?lua print(s) ?> mesh="asteroid_UV.mesh" />
     50          <Model position="0,0,0" scale="<?lua print(s) ?>" mesh="asteroid_UV.mesh" />
    5151        </attached>
    5252        <collisionShapes>
     
    145145            material="Examples/Flare"
    146146            colour="1.0, 0.5, 0.3"
    147             phase=<?lua print(-360/8*i)?>
     147            phase="<?lua print(-360/8*i)?>"
    148148            amplitude=0.1
    149149            frequency=0.5
     
    155155            material="Examples/Flare"
    156156            colour="1.0, 0.5, 0.3"
    157             phase=<?lua print(-360/8*i)?>
     157            phase="<?lua print(-360/8*i)?>"
    158158            amplitude=0.1
    159159            frequency=0.5
     
    203203        s = math.random() * 100
    204204    ?>
    205       <MovableEntity collisiontype=dynamic mass=<?lua print(s*10)?> position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.01 angularDamping=0 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
     205      <MovableEntity collisiontype=dynamic mass="<?lua print(s*10)?>" position="<?lua print(x) ?>,<?lua print(y) ?>,<?lua print(z) ?>" linearDamping=0.01 angularDamping=0 rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 100 - 15) ?>">
    206206        <attached>
    207           <Model position="0,0,0" scale=<?lua print(s) ?> mesh="asteroid_ice.mesh" />
     207          <Model position="0,0,0" scale="<?lua print(s) ?>" mesh="asteroid_ice.mesh" />
    208208        </attached>
    209209        <collisionShapes>
  • code/trunk/data/levels/teamBaseMatch.oxw

    r7679 r8079  
    5656          for i = 1, 10, 1 do
    5757        ?>
    58           <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
     58          <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay="<?lua print(math.random()) ?>" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
    5959            <events>
    6060              <spawn>
     
    9797          for i = 1, 10, 1 do
    9898        ?>
    99           <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
     99          <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay="<?lua print(math.random()) ?>" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
    100100            <events>
    101101              <spawn>
     
    138138          for i = 1, 10, 1 do
    139139        ?>
    140           <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
     140          <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay="<?lua print(math.random()) ?>" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
    141141            <events>
    142142              <spawn>
     
    178178          for i = 1, 10, 1 do
    179179        ?>
    180           <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
     180          <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay="<?lua print(math.random()) ?>" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
    181181            <events>
    182182              <spawn>
     
    219219          for i = 1, 10, 1 do
    220220        ?>
    221           <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay=<?lua print(math.random()) ?> source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
     221          <ParticleSpawner position="<?lua print(math.random() * 400 - 200) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" startdelay="<?lua print(math.random()) ?>" source="Orxonox/BigExplosion1part1" lifetime=2.0 loop=0 autostart=0>
    222222            <events>
    223223              <spawn>
  • code/trunk/data/levels/testSwallow.oxw

    r7679 r8079  
    4646?>
    4747
    48     <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass=<?lua print(j * 50) ?> <?lua end ?> scale=<?lua print(j * 5) ?> rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
     48    <MovableEntity position="<?lua print(x + math.random() * 10000-2500) ?>,<?lua print(y + math.random() * 5000-2500) ?>,<?lua print(z + math.random() * 1000-500) ?>" <?lua if i == 5 then ?> collisionType=dynamic linearDamping=0.8 angularDamping=0 mass="<?lua print(j * 50) ?>" <?lua end ?> scale="<?lua print(j * 5) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
    4949      <attached>
    50         <Model position="0,0,0" scale=<?lua print(j * 10) ?> mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
     50        <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
    5151      </attached>
    5252      <?lua if i == 5 then ?><collisionShapes>
  • code/trunk/data/levels/underAttack.oxw

    r7679 r8079  
    3636        </attached>
    3737          <collisionShapes>
    38             <SphereCollisionShape radius=<?lua print(x) ?> position="0,0,0" />
     38            <SphereCollisionShape radius="<?lua print(x) ?>" position="0,0,0" />
    3939          </collisionShapes>
    4040      </MovableEntity>
     
    9999            material="Examples/Flare"
    100100            colour="1.0, 0.5, 0.3"
    101             phase=<?lua print(-360/8*i)?>
     101            phase="<?lua print(-360/8*i)?>"
    102102            amplitude=0.1
    103103            frequency=0.5
     
    109109            material="Examples/Flare"
    110110            colour="1.0, 0.5, 0.3"
    111             phase=<?lua print(-360/8*i)?>
     111            phase="<?lua print(-360/8*i)?>"
    112112            amplitude=0.1
    113113            frequency=0.5
  • code/trunk/data/overlays/debug.oxo

    r6417 r8079  
    6666    />
    6767
     68    <PauseNotice
     69     name     = "pausenotice"
     70     position = "0.5, 0.1"
     71     font     = "VeraMono"
     72     textsize = 0.03
     73     colour   = "1.0, 1.0, 1.0, 1.0"
     74     align    = "center"
     75    />
     76
    6877    <AnnounceMessage
    6978     name     = "announcemessage"
  • code/trunk/src/CMakeLists.txt

    r7955 r8079  
    119119ADD_SUBDIRECTORY(libraries)
    120120ADD_SUBDIRECTORY(orxonox)
     121SET(ORXONOX_MODULES CACHE INTERNAL "")
    121122ADD_SUBDIRECTORY(modules)
    122123
  • code/trunk/src/external/enet/win32.c

    r7954 r8079  
    1111#define ENET_BUILDING_LIB 1
    1212#include "enet/enet.h"
     13#include <ws2tcpip.h>
    1314
    1415static enet_uint32 timeBase = 0;
  • code/trunk/src/libraries/core/CMakeLists.txt

    r7284 r8079  
    3535  OrxonoxClass.cc
    3636  Resource.cc
    37   WindowEventListener.cc
    3837
    3938  # hierarchy
     
    4948  Template.cc
    5049  XMLPort.cc
     50
     51COMPILATION_BEGIN ListenerCompilation.cc
     52  ViewportEventListener.cc
     53  WindowEventListener.cc
    5154  XMLNameListener.cc
     55COMPILATION_END
    5256
    5357COMPILATION_BEGIN FilesystemCompilation.cc
     
    7680    Game.h
    7781    GameMode.h
     82    GraphicsManager.h
    7883    GUIManager.h
    7984    Loader.h
  • code/trunk/src/libraries/core/Core.cc

    r7872 r8079  
    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/trunk/src/libraries/core/Core.h

    r7870 r8079  
    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/trunk/src/libraries/core/CorePrereqs.h

    r7849 r8079  
    182182    class Thread;
    183183    class ThreadPool;
     184    class ViewportEventListener;
    184185    template <class T>
    185186    class WeakPtr;
  • code/trunk/src/libraries/core/GUIManager.cc

    r7876 r8079  
    3232#include <boost/bind.hpp>
    3333#include <memory>
    34 extern "C" {
    35 #include <lua.h>
    36 }
     34
    3735#include <CEGUIDefaultLogger.h>
    3836#include <CEGUIExceptions.h>
     
    107105    SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, false);
    108106    SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
     107    SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
    109108
    110109    /**
     
    284283    {
    285284        GUIManager::getInstance().executeCode("hideMenuSheet(\"" + name + "\")");
     285    }
     286
     287    /**
     288    @brief
     289        Toggles specified GUI.
     290        If the GUI with the input name is already shown and on the top, it is hidden, else it is shown.
     291    */
     292    /*static*/ void GUIManager::toggleGUI(const std::string& name, bool bHidePrevious, bool bNoInput)
     293    {
     294        GUIManager::getInstance().executeCode("getGUIFirstActive(\"" + name + "\", " + multi_cast<std::string>(bHidePrevious) + ", " + multi_cast<std::string>(bNoInput) + ")");
     295    }
     296
     297    /**
     298    @brief
     299        Helper method to toggle a specified GUI.
     300        Is called by lua.
     301    */
     302    void GUIManager::toggleGUIHelper(const std::string& name, bool bHidePrevious, bool bNoInput, bool show)
     303    {
     304        if(show)
     305            GUIManager::showGUI(name, bHidePrevious, bNoInput);
     306        else
     307            GUIManager::hideGUI(name);
    286308    }
    287309
     
    512534    void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight)
    513535    {
    514         this->guiRenderer_->setDisplaySize(CEGUI::Size(newWidth, newHeight));
    515     }
    516 
    517     /**
    518         @brief Notify CEGUI if the windows loses the focus (stops higlight of menu items, etc).
     536        this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
     537    }
     538
     539    /**
     540        @brief Notify CEGUI if the windows loses the focus (stops highlighting of menu items, etc).
    519541    */
    520542    void GUIManager::windowFocusChanged(bool bFocus)
  • code/trunk/src/libraries/core/GUIManager.h

    r7874 r8079  
    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        /**
     98        @brief Helper method to get the developer's mode without having to export Core.h.
     99        @see Core::inDevMode
     100        */
     101        static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export
    93102
    94103        //! Creates a new InputState to be used with a GUI Sheet
  • code/trunk/src/libraries/core/Game.cc

    r7284 r8079  
    5050#include "GameMode.h"
    5151#include "GameState.h"
     52#include "GraphicsManager.h"
    5253#include "GUIManager.h"
    5354#include "command/ConsoleCommand.h"
     
    6061    static void printFPS()
    6162        { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
    62     SetConsoleCommand("printFPS", &printFPS);
     63    SetConsoleCommand("Stats", "printFPS", &printFPS);
    6364    static void printTickTime()
    6465        { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
    65     SetConsoleCommand("printTickTime", &printTickTime);
     66    SetConsoleCommand("Stats", "printTickTime", &printTickTime);
    6667
    6768    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
     
    142143        SetConfigValue(statisticsAvgLength_, 1000000)
    143144            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
    144         SetConfigValue(fpsLimit_, 50)
     145
     146        SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)
    145147            .description("Sets the desired frame rate (0 for no limit).");
    146148    }
     
    207209
    208210            // Limit frame rate
    209             this->updateFPSLimiter();
     211            static bool hasVSync = GraphicsManager::getInstance().hasVSyncEnabled(); // can be static since changes of VSync currently require a restart
     212            if (this->fpsLimit_ > 0 && !hasVSync)
     213                this->updateFPSLimiter();
    210214        }
    211215
  • code/trunk/src/libraries/core/GraphicsManager.cc

    r7874 r8079  
    4949#include "SpecialConfig.h"
    5050#include "util/Clock.h"
     51#include "util/Convert.h"
    5152#include "util/Exception.h"
    5253#include "util/StringUtils.h"
     
    5758#include "Game.h"
    5859#include "GameMode.h"
     60#include "GUIManager.h"
    5961#include "Loader.h"
    6062#include "MemoryArchive.h"
    6163#include "PathConfig.h"
     64#include "ViewportEventListener.h"
    6265#include "WindowEventListener.h"
    6366#include "XMLFile.h"
    6467#include "command/ConsoleCommand.h"
     68#include "input/InputManager.h"
    6569
    6670namespace orxonox
    6771{
     72    static const std::string __CC_GraphicsManager_group = "GraphicsManager";
     73    static const std::string __CC_setScreenResolution_name = "setScreenResolution";
     74    static const std::string __CC_setFSAA_name = "setFSAA";
     75    static const std::string __CC_setVSync_name = "setVSync";
     76    DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name, &prototype::string__uint_uint_bool);
     77    DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name, &prototype::string__string);
     78    DeclareConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name, &prototype::string__bool);
     79
    6880    static const std::string __CC_printScreen_name = "printScreen";
    6981    DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void);
     
    95107        , renderWindow_(0)
    96108        , viewport_(0)
     109        , lastFrameStartTime_(0.0f)
     110        , lastFrameEndTime_(0.0f)
    97111    {
    98112        RegisterObject(GraphicsManager);
     
    136150        Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get());
    137151        ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
     152        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction();
     153        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).resetFunction();
     154        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).resetFunction();
    138155
    139156        // Undeclare the resources
     
    304321        CCOUT(4) << "Configuring Renderer" << std::endl;
    305322
    306         if (!ogreRoot_->restoreConfig() || Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp())
     323        bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();
     324        if (updatedConfig)
     325            COUT(2) << "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << std::endl;
     326
     327        if (!ogreRoot_->restoreConfig() || updatedConfig)
    307328        {
    308329            if (!ogreRoot_->showConfigDialog())
     
    330351        // add console commands
    331352        ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this);
     353        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).setFunction(&GraphicsManager::setScreenResolution, this);
     354        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setFSAA_name).setFunction(&GraphicsManager::setFSAA, this);
     355        ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).setFunction(&GraphicsManager::setVSync, this);
    332356    }
    333357
     
    343367    @note
    344368        A note about the Ogre::FrameListener: Even though we don't use them,
    345         they still get called. However, the delta times are not correct (except
    346         for timeSinceLastFrame, which is the most important). A little research
    347         as shown that there is probably only one FrameListener that doesn't even
    348         need the time. So we shouldn't run into problems.
     369        they still get called.
    349370    */
    350371    void GraphicsManager::postUpdate(const Clock& time)
    351372    {
     373        // Time before rendering
     374        uint64_t timeBeforeTick = time.getRealMicroseconds();
     375
     376        // Ogre's time keeping object
    352377        Ogre::FrameEvent evt;
    353         evt.timeSinceLastFrame = time.getDeltaTime();
    354         evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway
    355 
    356         // don't forget to call _fireFrameStarted to OGRE to make sure
    357         // everything goes smoothly
     378
     379        // Translate to Ogre float times before the update
     380        float temp = lastFrameStartTime_;
     381        lastFrameStartTime_ = (float)timeBeforeTick * 0.000001f;
     382        evt.timeSinceLastFrame = lastFrameStartTime_ - temp;
     383        evt.timeSinceLastEvent = lastFrameStartTime_ - lastFrameEndTime_;
     384
     385        // Ogre requires the time too
    358386        ogreRoot_->_fireFrameStarted(evt);
    359387
     
    361389        // This calls the WindowEventListener objects.
    362390        Ogre::WindowEventUtilities::messagePump();
    363         // make sure the window stays active even when not focused
     391        // Make sure the window stays active even when not focused
    364392        // (probably only necessary on windows)
    365393        this->renderWindow_->setActive(true);
    366 
    367         // Time before rendering
    368         uint64_t timeBeforeTick = time.getRealMicroseconds();
    369394
    370395        // Render frame
     
    375400        Game::getInstance().subtractTickTime((int32_t)(timeAfterTick - timeBeforeTick));
    376401
    377         // again, just to be sure OGRE works fine
    378         ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
     402        // Translate to Ogre float times after the update
     403        temp = lastFrameEndTime_;
     404        lastFrameEndTime_ = (float)timeBeforeTick * 0.000001f;
     405        evt.timeSinceLastFrame = lastFrameEndTime_ - temp;
     406        evt.timeSinceLastEvent = lastFrameEndTime_ - lastFrameStartTime_;
     407
     408        // Ogre also needs the time after the frame finished
     409        ogreRoot_->_fireFrameEnded(evt);
    379410    }
    380411
    381412    void GraphicsManager::setCamera(Ogre::Camera* camera)
    382413    {
     414        Ogre::Camera* oldCamera = this->viewport_->getCamera();
     415
    383416        this->viewport_->setCamera(camera);
     417        GUIManager::getInstance().setCamera(camera);
     418
     419        for (ObjectList<ViewportEventListener>::iterator it = ObjectList<ViewportEventListener>::begin(); it != ObjectList<ViewportEventListener>::end(); ++it)
     420            it->cameraChanged(this->viewport_, oldCamera);
    384421    }
    385422
     
    440477    bool GraphicsManager::isFullScreen() const
    441478    {
     479        return this->renderWindow_->isFullScreen();
     480    }
     481
     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
     492    bool GraphicsManager::hasVSyncEnabled() const
     493    {
    442494        Ogre::ConfigOptionMap& options = ogreRoot_->getRenderSystem()->getConfigOptions();
    443         if (options.find("Full Screen") != options.end())
    444         {
    445             if (options["Full Screen"].currentValue == "Yes")
    446                 return true;
    447             else
    448                 return false;
    449         }
     495        Ogre::ConfigOptionMap::iterator it = options.find("VSync");
     496        if (it != options.end())
     497            return (it->second.currentValue == "Yes");
    450498        else
    451         {
    452             COUT(0) << "Could not find 'Full Screen' render system option. Fix This!!!" << std::endl;
    453499            return false;
    454         }
     500    }
     501
     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
     512    std::string GraphicsManager::setScreenResolution(unsigned int width, unsigned int height, bool fullscreen)
     513    {
     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
     533        this->ogreRoot_->getRenderSystem()->setConfigOption("Full Screen", fullscreen ? "Yes" : "No");
     534
     535        std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
     536
     537        if (validate == "")
     538        {
     539            GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height);
     540            this->ogreRoot_->saveConfig();
     541            Core::getInstance().updateOgreConfigTimestamp();
     542            // Also reload the input devices
     543            InputManager::getInstance().reload();
     544        }
     545
     546        return validate;
     547    }
     548
     549    std::string GraphicsManager::setFSAA(const std::string& mode)
     550    {
     551        this->ogreRoot_->getRenderSystem()->setConfigOption("FSAA", mode);
     552
     553        std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
     554
     555        if (validate == "")
     556        {
     557            //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
     558            this->ogreRoot_->saveConfig();
     559            Core::getInstance().updateOgreConfigTimestamp();
     560        }
     561
     562        return validate;
     563    }
     564
     565    std::string GraphicsManager::setVSync(bool vsync)
     566    {
     567        this->ogreRoot_->getRenderSystem()->setConfigOption("VSync", vsync ? "Yes" : "No");
     568
     569        std::string validate = this->ogreRoot_->getRenderSystem()->validateConfigOptions();
     570
     571        if (validate == "")
     572        {
     573            //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
     574            this->ogreRoot_->saveConfig();
     575            Core::getInstance().updateOgreConfigTimestamp();
     576        }
     577
     578        return validate;
    455579    }
    456580
  • code/trunk/src/libraries/core/GraphicsManager.h

    r7401 r8079  
    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
     87        bool hasVSyncEnabled() const;
     88        std::string getFSAAMode() const;
     89// tolua_end
    7790
    7891        void upgradeToGraphics();
     
    96109        // console commands
    97110        void printScreen();
     111        std::string setScreenResolution(unsigned int width, unsigned int height, bool fullscreen);
     112        std::string setFSAA(const std::string& mode);
     113        std::string setVSync(bool vsync);
    98114
    99115        scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
     
    105121        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
    106122        Ogre::Viewport*     viewport_;                 //!< default full size viewport
     123        float               lastFrameStartTime_;       //!< Time stamp of the beginning of the last frame
     124        float               lastFrameEndTime_;         //!< Time stamp of the end of the last frame
    107125
    108126        // XML files for the resources and the debug overlay
     
    121139
    122140        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
     141// tolua_begin
    123142    };
    124143}
     144// tolua_end
    125145
    126146#endif /* _GraphicsManager_H__ */
  • code/trunk/src/libraries/core/Loader.cc

    r7648 r8079  
    147147        Returns true if successful.
    148148    */
    149     bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose)
     149    bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose, bool bRemoveLuaTags)
    150150    {
    151151        if (!file)
     
    155155
    156156        std::string xmlInput;
    157         if (file->getLuaSupport())
     157        if (file->getLuaSupport() && !bRemoveLuaTags)
    158158        {
    159159            // Use the LuaState to replace the XML tags (calls our function)
     
    172172            }
    173173            xmlInput = Resource::open(file->getFilename())->getAsString();
     174
     175            if (bRemoveLuaTags)
     176            {
     177                // Remove all Lua code.
     178                // Note: we only need this to speed up parsing of level files at the
     179                // start of the program.
     180                // Assumption: the LevelInfo tag does not use Lua scripting
     181                xmlInput = removeLuaTags(xmlInput);
     182            }
    174183        }
    175184
     
    271280    }
    272281
    273     std::string Loader::replaceLuaTags(const std::string& text)
    274     {
    275         // create map with all Lua tags
    276         std::map<size_t, bool> luaTags;
     282    bool Loader::getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags)
     283    {
     284        // fill map with all Lua tags
    277285        {
    278286            size_t pos = 0;
     
    328336            {
    329337                COUT(2) << "Warning: Error in level file" << std::endl;
    330                 // todo: errorhandling
    331                 return "";
    332             }
    333         }
     338                // TODO: error handling
     339                return false;
     340            }
     341        }
     342
     343        return true;
     344    }
     345
     346    std::string Loader::replaceLuaTags(const std::string& text)
     347    {
     348        // create a map with all lua tags
     349        std::map<size_t, bool> luaTags;
     350        if (!getLuaTags(text, luaTags))
     351            return "";
    334352
    335353        // Use a stringstream object to speed up the parsing
     
    421439        return output.str();
    422440    }
     441
     442    std::string Loader::removeLuaTags(const std::string& text)
     443    {
     444        // create a map with all lua tags
     445        std::map<size_t, bool> luaTags;
     446        if (!getLuaTags(text, luaTags))
     447            return "";
     448
     449        // Use a stringstream object to speed up the concatenation
     450        std::ostringstream output;
     451
     452        // cut the original string into pieces and only write the non Lua parts
     453        std::map<size_t, bool>::iterator it = luaTags.begin();
     454        bool bLuaCode = false;
     455        size_t start = 0;
     456        size_t end = 0;
     457
     458        do
     459        {
     460            if (it != luaTags.end())
     461                end = (it++)->first;
     462            else
     463                end = std::string::npos;
     464
     465            if (!bLuaCode)
     466            {
     467                output << text.substr(start, end - start);
     468                start = end + 5;
     469            }
     470            else
     471                start = end + 2;
     472
     473            bLuaCode = !bLuaCode;
     474        }
     475        while (end != std::string::npos);
     476
     477        return output.str();
     478    }
    423479}
  • code/trunk/src/libraries/core/Loader.h

    r7648 r8079  
    4242#include "CorePrereqs.h"
    4343
     44#include <map>
    4445#include <vector>
    4546#include "ClassTreeMask.h"
     
    6162            static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
    6263
    63             static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
     64            static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
     65                             bool verbose = true, bool bRemoveLuaTags = false);
    6466            static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
    6567            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
    6668
    6769            static std::string replaceLuaTags(const std::string& text);
     70            static std::string removeLuaTags(const std::string& text);
    6871
    6972            static ClassTreeMask currentMask_s;
    7073
    7174        private:
     75            static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags);
     76
    7277            static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s;
    7378    };
  • code/trunk/src/libraries/core/OrxonoxClass.h

    r7850 r8079  
    194194
    195195        protected:
     196            virtual ~DestructionListener() {}
     197
    196198            inline void registerAsDestructionListener(OrxonoxClass* object)
    197199                { if (object) { object->registerDestructionListener(this); } }
  • code/trunk/src/libraries/core/WeakPtr.h

    r7850 r8079  
    129129
    130130            /// Destructor
    131             inline ~WeakPtr()
     131            inline virtual ~WeakPtr()
    132132            {
    133133                this->unregisterAsDestructionListener(this->base_);
  • code/trunk/src/libraries/core/command/CommandEvaluation.h

    r7401 r8079  
    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/trunk/src/libraries/core/command/ConsoleCommand.h

    r7861 r8079  
    317317        inline void void__void(void) {}
    318318        inline void void__string(const std::string&) {}
     319
     320        inline std::string string__bool(bool) { return ""; }
     321        inline std::string string__string(const std::string&) { return ""; }
     322        inline std::string string__uint_uint_bool(unsigned int, unsigned int, bool) { return ""; }
    319323    }
    320324
  • code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc

    r7401 r8079  
    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/trunk/src/libraries/core/command/Shell.cc

    r7401 r8079  
    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/trunk/src/libraries/core/command/TclBind.cc

    r7401 r8079  
    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/trunk/src/libraries/core/command/TclBind.h

    r7401 r8079  
    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/trunk/src/libraries/core/command/TclThreadManager.cc

    r7401 r8079  
    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/trunk/src/libraries/core/input/InputManager.cc

    r7874 r8079  
    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/trunk/src/libraries/core/input/InputManager.h

    r7874 r8079  
    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/trunk/src/libraries/core/input/KeyBinder.cc

    r7958 r8079  
    431431                        // decrease counter
    432432                        button->nCommands_[mode_index]--;
    433                         // note: we don't replace the old array - it's not one element too large, but no one cares since nCommands_ defines the size
     433                        // old array would not get deleted if nCommands_ is now 0
     434                        // otherwise: nobody cares about an array that is one element too large - nCommands_ defines the size
     435                        if (button->nCommands_[mode_index] == 0)
     436                        {
     437                            delete[] button->commands_[mode_index];
     438                            button->commands_[mode_index] = 0;
     439                        }
    434440
    435441                        // decrement the index since we shifted the array and continue searching for more occurrences of the command
  • code/trunk/src/libraries/core/input/Keyboard.cc

    r6422 r8079  
    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/trunk/src/libraries/core/input/Keyboard.h

    r7809 r8079  
    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/trunk/src/libraries/network/Host.cc

    r7801 r8079  
    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/trunk/src/libraries/tools/ResourceLocation.cc

    r7709 r8079  
    3030
    3131#include <OgreResourceGroupManager.h>
     32#include <OgreException.h>
    3233#include <boost/filesystem.hpp>
    3334
  • code/trunk/src/libraries/tools/Shader.cc

    r6417 r8079  
    3030
    3131#include <OgreCompositorManager.h>
    32 #include <OgreCompositorInstance.h>
    33 #include <OgreSceneManager.h>
    3432#include <OgreRoot.h>
    3533#include <OgrePlugin.h>
    36 #include <OgreMaterial.h>
    37 #include <OgreTechnique.h>
    38 #include <OgrePass.h>
    39 #include <OgreMaterialManager.h>
    4034
    4135#include "core/CoreIncludes.h"
     
    4539namespace orxonox
    4640{
    47     bool Shader::bLoadedCgPlugin_s = false;
    48     Shader::MaterialMap Shader::parameters_s;
    49 
     41    /**
     42        @brief Initializes the values and sets the scene manager.
     43    */
    5044    Shader::Shader(Ogre::SceneManager* scenemanager) : compositorInstance_(0)
    5145    {
     
    5347
    5448        this->scenemanager_ = scenemanager;
    55         this->compositorInstance_ = 0;
    5649        this->bVisible_ = true;
    5750        this->bLoadCompositor_ = GameMode::showsGraphics();
    58         this->bViewportInitialized_ = false;
    59 
    60         if (this->bLoadCompositor_ && Ogre::Root::getSingletonPtr())
    61         {
    62             Shader::bLoadedCgPlugin_s = false;
     51        this->registeredAsListener_ = false;
     52
     53        static bool hasCgProgramManager = Shader::hasCgProgramManager();
     54
     55        this->bLoadCompositor_ &= hasCgProgramManager;
     56    }
     57
     58    /**
     59        @brief Removes the compositor and frees the resources.
     60    */
     61    Shader::~Shader()
     62    {
     63        if (this->compositorInstance_ && GraphicsManager::getInstance().getViewport())
     64            Ogre::CompositorManager::getSingleton().removeCompositor(GraphicsManager::getInstance().getViewport(), this->compositorName_);
     65    }
     66
     67    /**
     68        @brief Inherited from ViewportEventListener - called if the camera changes.
     69
     70        Since the new camera could be in a different scene, the shader has to make sure
     71        it deactivates or activates itself accordingly.
     72
     73        Additionally the shader has to be turned off and on even if the camera stays in
     74        the same scene to fix a weird behavior of Ogre.
     75    */
     76    void Shader::cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera)
     77    {
     78        if (!this->bLoadCompositor_ || !this->scenemanager_)
     79            return;
     80
     81        // load the compositor if not already done
     82        if (!this->compositorName_.empty() && !this->compositorInstance_)
     83            this->changedCompositorName(viewport);
     84
     85        // update compositor in viewport (shader should only be active if the current camera is in the same scene as the shader)
     86
     87        // Note:
     88        // The shader needs also to be switched off and on after changing the camera in the
     89        // same scene to avoid weird behaviour with active compositors while switching the
     90        // camera (like freezing the image)
     91        //
     92        // Last known Ogre version needing this workaround:
     93        // 1.4.8
     94        // 1.7.2
     95
     96        if (oldCamera && this->scenemanager_ == oldCamera->getSceneManager())
     97            Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, false);
     98
     99        if (viewport->getCamera() && this->scenemanager_ == viewport->getCamera()->getSceneManager())
     100            Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, this->isVisible());
     101    }
     102
     103    /**
     104        @brief Changes the compositor - default viewport.
     105    */
     106    void Shader::changedCompositorName()
     107    {
     108        // For the moment, we get the viewport always from the graphics manager
     109        // TODO: Try to support multiple viewports - note however that scenemanager_->getCurrentViewport() returns NULL
     110        //       after switching to a camera in a different scene (only for the first time this scene is displayed though)
     111        this->changedCompositorName(GraphicsManager::getInstance().getViewport());
     112    }
     113
     114    /**
     115        @brief Changes the compositor.
     116    */
     117    void Shader::changedCompositorName(Ogre::Viewport* viewport)
     118    {
     119        if (this->bLoadCompositor_)
     120        {
     121            assert(viewport);
     122            if (this->compositorInstance_)
     123            {
     124                // remove the old compositor, remove the listener
     125                Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositorName_);
     126                this->compositorInstance_->removeListener(this);
     127                this->compositorInstance_ = 0;
     128            }
     129            if (!this->compositorName_.empty())
     130            {
     131                // add the new compositor
     132                this->compositorInstance_ = Ogre::CompositorManager::getSingleton().addCompositor(viewport, this->compositorName_);
     133                if (this->compositorInstance_)
     134                {
     135                    // register as listener if required
     136                    if (this->registeredAsListener_)
     137                        this->compositorInstance_->addListener(this);
     138                    // set visibility according to the isVisible() and the camera/viewport
     139                    if (viewport->getCamera())
     140                        Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, this->isVisible() && viewport->getCamera() && this->scenemanager_ == viewport->getCamera()->getSceneManager());
     141                }
     142                else
     143                    COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositorName_ << "\"." << std::endl;
     144            }
     145            this->oldcompositorName_ = this->compositorName_;
     146        }
     147    }
     148
     149    /**
     150        @brief Changes the visibility of the shader. Doesn't free any resources if set to invisible.
     151    */
     152    void Shader::updateVisibility()
     153    {
     154        if (this->compositorInstance_)
     155            Ogre::CompositorManager::getSingleton().setCompositorEnabled(GraphicsManager::getInstance().getViewport(), this->compositorName_, this->isVisible());
     156    }
     157
     158    /**
     159        @brief Defines a new integer value for a given parameter. The parameter will be updated if the compositor is rendered the next time.
     160    */
     161    void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, int value)
     162    {
     163        ParameterContainer container = {technique, pass, parameter, value, 0.0f, MT_Type::Int};
     164        this->parameters_.push_back(container);
     165        this->addAsListener();
     166    }
     167
     168    /**
     169        @brief Defines a new float value for a given parameter. The parameter will be updated if the compositor is rendered the next time.
     170    */
     171    void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, float value)
     172    {
     173        ParameterContainer container = {technique, pass, parameter, 0, value, MT_Type::Float};
     174        this->parameters_.push_back(container);
     175        this->addAsListener();
     176    }
     177
     178    /**
     179        @brief Registers the shader as CompositorInstance::Listener at the compositor. Used to change parameters.
     180    */
     181    void Shader::addAsListener()
     182    {
     183        if (!this->registeredAsListener_)
     184        {
     185            this->registeredAsListener_ = true;
     186            if (this->compositorInstance_)
     187                this->compositorInstance_->addListener(this);
     188        }
     189    }
     190
     191    /**
     192        @brief Inherited by Ogre::CompositorInstance::Listener, called whenever the material is rendered. Used to change parameters.
     193    */
     194    void Shader::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr)
     195    {
     196        // iterate through the list of parameters
     197        for (std::list<ParameterContainer>::iterator it = this->parameters_.begin(); it != this->parameters_.end(); ++it)
     198        {
     199            Ogre::Technique* techniquePtr = materialPtr->getTechnique(it->technique_);
     200            if (techniquePtr)
     201            {
     202                Ogre::Pass* passPtr = techniquePtr->getPass(it->pass_);
     203                if (passPtr)
     204                {
     205                    // change the value of the parameter depending on its type
     206                    switch (it->valueType_)
     207                    {
     208                        case MT_Type::Int:
     209                            passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueInt_);
     210                            break;
     211                        case MT_Type::Float:
     212                            passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueFloat_);
     213                            break;
     214                        default:
     215                            break;
     216                    }
     217                }
     218                else
     219                    COUT(2) << "Warning: No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << std::endl;
     220            }
     221            else
     222                COUT(2) << "Warning: No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << std::endl;
     223        }
     224        this->parameters_.clear();
     225    }
     226
     227    /**
     228        @brief Detects if the Cg program manager plugin is active.
     229    */
     230    /* static */ bool Shader::hasCgProgramManager()
     231    {
     232        if (Ogre::Root::getSingletonPtr())
     233        {
    63234            const Ogre::Root::PluginInstanceList& plugins = Ogre::Root::getSingleton().getInstalledPlugins();
    64235            for (size_t i = 0; i < plugins.size(); ++i)
    65             {
    66236                if (plugins[i]->getName() == "Cg Program Manager")
    67                 {
    68                     Shader::bLoadedCgPlugin_s = true;
    69                     break;
    70                 }
    71             }
    72         }
    73 
    74         this->bLoadCompositor_ &= Shader::bLoadedCgPlugin_s;
    75     }
    76 
    77     Shader::~Shader()
    78     {
    79         if (this->compositorInstance_ && this->bLoadCompositor_)
    80         {
    81             Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
    82             assert(viewport);
    83             Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->compositor_);
    84         }
    85 
    86     }
    87 
    88     void Shader::setSceneManager(Ogre::SceneManager* scenemanager)
    89     {
    90         this->scenemanager_ = scenemanager;
    91         this->bViewportInitialized_ = false;
    92     }
    93 
    94     void Shader::tick(float dt)
    95     {
    96         SUPER(Shader, tick, dt);
    97 
    98         if (this->bLoadCompositor_ && !this->bViewportInitialized_ && this->scenemanager_ && this->scenemanager_->getCurrentViewport())
    99         {
    100             this->bViewportInitialized_ = true;
    101             this->updateVisibility();
    102         }
    103     }
    104 
    105     void Shader::changedCompositor()
    106     {
    107         if (this->bLoadCompositor_)
    108         {
    109             Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
    110             assert(viewport);
    111             if (!this->oldcompositor_.empty())
    112             {
    113                 Ogre::CompositorManager::getSingleton().removeCompositor(viewport, this->oldcompositor_);
    114                 this->compositorInstance_ = 0;
    115             }
    116             if (!this->compositor_.empty())
    117             {
    118                 this->compositorInstance_ = Ogre::CompositorManager::getSingleton().addCompositor(viewport, this->compositor_);
    119                 if (!this->compositorInstance_)
    120                     COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositor_ << "\"." << std::endl;
    121                 Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositor_, this->bViewportInitialized_ && this->isVisible());
    122             }
    123             this->oldcompositor_ = this->compositor_;
    124         }
    125     }
    126 
    127     void Shader::updateVisibility()
    128     {
    129         if (this->compositorInstance_ && this->scenemanager_)
    130             this->compositorInstance_->setEnabled(this->scenemanager_->getCurrentViewport() && this->isVisible());
    131     }
    132 
    133     void Shader::setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value)
    134     {
    135         if (Shader::_setParameter(material, technique, pass, parameter, value))
    136         {
    137             if (this->bViewportInitialized_ && this->compositorInstance_ && this->isVisible())
    138             {
    139                 this->compositorInstance_->setEnabled(false);
    140                 this->compositorInstance_->setEnabled(true);
    141             }
    142         }
    143     }
    144 
    145     void Shader::setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value)
    146     {
    147         if (Shader::_setParameter(material, technique, pass, parameter, value))
    148         {
    149             if (this->bViewportInitialized_ && this->compositorInstance_ && this->isVisible())
    150             {
    151                 this->compositorInstance_->setEnabled(false);
    152                 this->compositorInstance_->setEnabled(true);
    153             }
    154         }
    155     }
    156 
    157     bool Shader::_setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value)
    158     {
    159         ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);
    160         if (pointer)
    161         {
    162             if (pointer->first)
    163             {
    164                 if ((*static_cast<float*>(pointer->second)) != value)
    165                 {
    166                     (*static_cast<float*>(pointer->second)) = value;
    167237                    return true;
    168                 }
    169             }
    170             else
    171             {
    172                 if ((*static_cast<int*>(pointer->second)) != static_cast<int>(value))
    173                 {
    174                     (*static_cast<int*>(pointer->second)) = static_cast<int>(value);
    175                     return true;
    176                 }
    177             }
    178238        }
    179239        return false;
    180240    }
    181 
    182     bool Shader::_setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value)
    183     {
    184         ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);
    185         if (pointer)
    186         {
    187             if (pointer->first)
    188             {
    189                 if ((*static_cast<float*>(pointer->second)) != static_cast<float>(value))
    190                 {
    191                     (*static_cast<float*>(pointer->second)) = static_cast<float>(value);
    192                     return true;
    193                 }
    194             }
    195             else
    196             {
    197                 if ((*static_cast<int*>(pointer->second)) != value)
    198                 {
    199                     (*static_cast<int*>(pointer->second)) = value;
    200                     return true;
    201                 }
    202             }
    203         }
    204         return false;
    205     }
    206 
    207     float Shader::getParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
    208     {
    209         ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);
    210         if (pointer)
    211         {
    212             if (pointer->first)
    213                 return (*static_cast<float*>(pointer->second));
    214             else
    215                 return static_cast<float>(*static_cast<int*>(pointer->second));
    216         }
    217         else
    218             return 0;
    219     }
    220 
    221     bool Shader::getParameterIsFloat(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
    222     {
    223         ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);
    224         if (pointer)
    225             return pointer->first;
    226         else
    227             return false;
    228     }
    229 
    230     bool Shader::getParameterIsInt(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
    231     {
    232         ParameterPointer* pointer = Shader::getParameterPointer(material, technique, pass, parameter);
    233         if (pointer)
    234             return (!pointer->first);
    235         else
    236             return false;
    237     }
    238 
    239     Shader::ParameterPointer* Shader::getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
    240     {
    241         if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)
    242             return 0;
    243 
    244         MaterialMap::iterator material_iterator = Shader::parameters_s.find(material);
    245         if (material_iterator != Shader::parameters_s.end())
    246         {
    247             TechniqueVector& technique_vector = material_iterator->second;
    248             if (technique < technique_vector.size())
    249             {
    250                 PassVector& pass_vector = technique_vector[technique];
    251                 if (pass < pass_vector.size())
    252                 {
    253                     ParameterMap& parameter_map = pass_vector[pass];
    254                     ParameterMap::iterator parameter_iterator = parameter_map.find(parameter);
    255 
    256                     if (parameter_iterator != parameter_map.end())
    257                         return (&parameter_iterator->second);
    258                     else
    259                         COUT(2) << "Warning: No shader parameter \"" << parameter << "\" in pass " << pass << " in technique " << technique << " in material \"" << material << "\"." << std::endl;
    260                 }
    261                 else
    262                     COUT(2) << "Warning: No pass " << pass << " in technique " << technique << " in material \"" << material << "\" or pass has no shader." << std::endl;
    263             }
    264             else
    265                 COUT(2) << "Warning: No technique " << technique << " in material \"" << material << "\" or technique has no pass with shader." << std::endl;
    266         }
    267         else
    268         {
    269             bool foundAtLeastOneShaderParameter = false;
    270             Ogre::MaterialManager::ResourceMapIterator iterator = Ogre::MaterialManager::getSingleton().getResourceIterator();
    271             Ogre::Material* material_pointer = 0;
    272 
    273             while (iterator.hasMoreElements())
    274             {
    275                 Ogre::Resource* resource = iterator.getNext().get();
    276                 if (resource->getName() == material)
    277                     material_pointer = (Ogre::Material*)resource;
    278             }
    279 
    280             if (!material_pointer)
    281             {
    282                 COUT(2) << "Warning: No material with name \"" << material << "\" found." << std::endl;
    283                 return 0;
    284             }
    285 
    286             for (unsigned int t = 0; t < material_pointer->getNumTechniques(); ++t)
    287             {
    288                 Ogre::Technique* technique_pointer = material_pointer->getTechnique(t);
    289                 if (!technique_pointer)
    290                     continue;
    291 
    292                 for (unsigned int p = 0; p < technique_pointer->getNumPasses(); ++p)
    293                 {
    294                     Ogre::Pass* pass_pointer = technique_pointer->getPass(p);
    295                     if (!pass_pointer)
    296                         continue;
    297 
    298                     if (!pass_pointer->getFragmentProgramName().empty())
    299                     {
    300                         Ogre::GpuProgramParameters* parameter_pointer = pass_pointer->getFragmentProgramParameters().get();
    301                         if (!parameter_pointer)
    302                             continue;
    303 
    304                         const Ogre::GpuConstantDefinitionMap& constant_definitions = parameter_pointer->getConstantDefinitions().map;
    305                         for (Ogre::GpuConstantDefinitionMap::const_iterator definition_iterator = constant_definitions.begin(); definition_iterator != constant_definitions.end(); ++definition_iterator)
    306                         {
    307                             void* temp = (definition_iterator->second.isFloat())
    308                                             ? static_cast<void*>(parameter_pointer->getFloatPointer(definition_iterator->second.physicalIndex))
    309                                             : static_cast<void*>(parameter_pointer->getIntPointer(definition_iterator->second.physicalIndex));
    310                             ParameterPointer parameter_pointer = ParameterPointer(definition_iterator->second.isFloat(), temp);
    311 
    312                             TechniqueVector& technique_vector = Shader::parameters_s[material];
    313                             technique_vector.resize(technique + 1);
    314                             PassVector& pass_vector = technique_vector[technique];
    315                             pass_vector.resize(pass + 1);
    316                             pass_vector[pass][definition_iterator->first] = parameter_pointer;
    317                             foundAtLeastOneShaderParameter = true;
    318                         }
    319                     }
    320                 }
    321             }
    322 
    323             // recursive call if the material was added to the map
    324             if (foundAtLeastOneShaderParameter)
    325                 return Shader::getParameterPointer(material, technique, pass, parameter);
    326         }
    327         return 0;
    328     }
    329241}
  • code/trunk/src/libraries/tools/Shader.h

    r5781 r8079  
    3636#include <vector>
    3737
     38#include <OgreCompositorInstance.h>
     39
     40#include "util/MultiType.h"
    3841#include "util/OgreForwardRefs.h"
    39 #include "tools/interfaces/Tickable.h"
     42#include "core/ViewportEventListener.h"
    4043
    4144namespace orxonox
    4245{
    43     class _ToolsExport Shader : public Tickable
     46    /**
     47        @brief Shader is a wrapper class around Ogre::CompositorInstance. It provides some
     48        functions to easily change the visibility and parameters for shader programs.
     49    */
     50    class _ToolsExport Shader : public ViewportEventListener, public Ogre::CompositorInstance::Listener
    4451    {
    45         typedef std::pair<bool, void*>                  ParameterPointer;
    46         typedef std::map<std::string, ParameterPointer> ParameterMap;
    47         typedef std::vector<ParameterMap>               PassVector;
    48         typedef std::vector<PassVector>                 TechniqueVector;
    49         typedef std::map<std::string, TechniqueVector>  MaterialMap;
    50 
    5152        public:
    5253            Shader(Ogre::SceneManager* scenemanager = 0);
    5354            virtual ~Shader();
    5455
    55             virtual void tick(float dt);
    56 
     56            /// Defines if the shader is visible or not.
    5757            inline void setVisible(bool bVisible)
    5858            {
     
    6363                }
    6464            }
     65            /// Returns whether or not the shader is visible.
    6566            inline bool isVisible() const
    6667                { return this->bVisible_; }
    6768            void updateVisibility();
    6869
    69             inline void setCompositor(const std::string& compositor)
     70            /// Defines the compositor's name (located in a .compositor file).
     71            inline void setCompositorName(const std::string& name)
    7072            {
    71                 if (this->compositor_ != compositor)
     73                if (this->compositorName_ != name)
    7274                {
    73                     this->compositor_ = compositor;
    74                     this->changedCompositor();
     75                    this->compositorName_ = name;
     76                    this->changedCompositorName();
    7577                }
    7678            }
    77             inline const std::string& getCompositor() const
    78                 { return this->compositor_; }
    79             void changedCompositor();
     79            /// Returns the compositor's name.
     80            inline const std::string& getCompositorName() const
     81                { return this->compositorName_; }
     82            void changedCompositorName();
     83            void changedCompositorName(Ogre::Viewport* viewport);
    8084
    81             void setSceneManager(Ogre::SceneManager* scenemanager);
     85            /// Sets the scenemanager (usually provided in the constructor, but can be set later). Shouldn't be changed once it's set.
     86            inline void setSceneManager(Ogre::SceneManager* scenemanager)
     87                { this->scenemanager_ = scenemanager; }
     88            /// Returns the scene manager.
    8289            inline Ogre::SceneManager* getSceneManager() const
    8390                { return this->scenemanager_; }
    8491
    85             void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value);
    86             void setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value);
     92            virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera);
    8793
    88             static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, float value);
    89             static bool _setParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter, int value);
    90             static float getParameter(const std::string& material, size_t technique, size_t pass, const std::string& parameter);
    91             static bool  getParameterIsFloat(const std::string& material, size_t technique, size_t pass, const std::string& parameter);
    92             static bool  getParameterIsInt  (const std::string& material, size_t technique, size_t pass, const std::string& parameter);
    93             static ParameterPointer* getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter);
     94            void setParameter(size_t technique, size_t pass, const std::string& parameter, float value);
     95            void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);
     96
     97            virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr);
    9498
    9599        private:
    96             Ogre::SceneManager* scenemanager_;
    97             Ogre::CompositorInstance* compositorInstance_;
    98             bool bVisible_;
    99             bool bLoadCompositor_;
    100             bool bViewportInitialized_;
    101             std::string compositor_;
    102             std::string oldcompositor_;
     100            static bool hasCgProgramManager();
    103101
    104             static MaterialMap parameters_s;
    105             static bool bLoadedCgPlugin_s;
     102            Ogre::SceneManager* scenemanager_;              ///< The scenemanager for which the shader is active
     103            Ogre::CompositorInstance* compositorInstance_;  ///< The compositor instance representing the wrapped compositor
     104            bool bVisible_;                                 ///< True if the shader should be visible
     105            bool bLoadCompositor_;                          ///< True if the compositor should be loaded (usually false if no graphics)
     106            std::string compositorName_;                    ///< The name of the current compositor
     107            std::string oldcompositorName_;                 ///< The name of the previous compositor (used to unregister)
     108
     109        private:
     110            void addAsListener();
     111
     112            /// Helper struct to store parameters for shader programs.
     113            struct ParameterContainer
     114            {
     115                size_t technique_;          ///< The ID of the technique
     116                size_t pass_;               ///< The ID of the pass
     117                std::string parameter_;     ///< The name of the parameter
     118
     119                int valueInt_;              ///< The desired int value of the parameter
     120                float valueFloat_;          ///< The desired float value of the parameter
     121
     122                MT_Type::Value valueType_;  ///< The type of the parameter (currently only int or float)
     123            };
     124
     125            std::list<ParameterContainer> parameters_;  ///< The list of parameters that should be set on the next update
     126            bool registeredAsListener_;                 ///< True if the shader should register itself as listener at the compositor
    106127    };
    107128}
  • code/trunk/src/libraries/tools/Timer.cc

    r7401 r8079  
    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/trunk/src/libraries/tools/Timer.h

    r7851 r8079  
    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/trunk/src/libraries/tools/ToolsPrereqs.h

    r7163 r8079  
    8585    class Mesh;
    8686    class ParticleInterface;
     87    class RealTimer;
    8788    class ResourceCollection;
    8889    class ResourceLocation;
  • code/trunk/src/modules/designtools/ScreenshotManager.cc

    r7284 r8079  
    2525    {
    2626        Ogre::RenderWindow* pRenderWindow = GraphicsManager::getInstance().getRenderWindow();
    27         int gridSize = 3;
    28         std::string fileExtension = ".png";
    29         bool overlayFlag = true;
    3027
    3128        //set file extension for the Screenshot files
    32         mFileExtension   = fileExtension;
     29        this->mFileExtension_  = ".png";
    3330        // the gridsize
    34         mGridSize        = gridSize;
     31        this->mGridSize_ = 3;
    3532        // flag for overlay rendering
    36         mDisableOverlays = overlayFlag;
     33        this->mDisableOverlays_ = true;
    3734        //get current window size
    38         mWindowWidth   = pRenderWindow->getWidth();
    39         mWindowHeight  = pRenderWindow->getHeight();
     35        this->mWindowWidth_   = pRenderWindow->getWidth();
     36        this->mWindowHeight_  = pRenderWindow->getHeight();
    4037        //create temporary texture
    41         mTempTex = Ogre::TextureManager::getSingleton().createManual("ScreenShotTex",
    42                                                                   Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D,
    43                                                                     mWindowWidth, mWindowHeight,0, Ogre::PF_B8G8R8, Ogre::TU_RENDERTARGET);
     38        this->mTempTex_ = Ogre::TextureManager::getSingleton().createManual("ScreenShotTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, this->mWindowWidth_, this->mWindowHeight_, 0, Ogre::PF_B8G8R8, Ogre::TU_RENDERTARGET);
    4439
    4540        //get The current Render Target of the temp Texture
    46         mRT = mTempTex->getBuffer()->getRenderTarget();
     41        this->mRT_ = this->mTempTex_->getBuffer()->getRenderTarget();
    4742
    4843        //HardwarePixelBufferSharedPtr to the Buffer of the temp Texture
    49         mBuffer = mTempTex->getBuffer();
     44        this->mBuffer_ = this->mTempTex_->getBuffer();
    5045
    5146        //create PixelBox
    52             uint8_t* data_ = new uint8_t[(mWindowWidth * mGridSize) * (mWindowHeight * mGridSize) * 3];
    53         mFinalPicturePB = Ogre::PixelBox(mWindowWidth * mGridSize,mWindowHeight * mGridSize,1,Ogre::PF_B8G8R8,data_);
     47        uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3];
     48        this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_);
    5449
    5550    }
     
    6358
    6459
    65     /* Creates a screenshot with the given camera.
    66     * @param camera Pointer to the camera "looking at" the scene of interest
    67     * @param fileName the filename of the screenshot file.
     60    /**
     61    @brief
     62        Creates a screenshot with the given camera.
     63    @param camera
     64        Pointer to the camera "looking at" the scene of interest
     65    @param fileName
     66        the filename of the screenshot file.
    6867    */
    6968    void ScreenshotManager::makeScreenshot() const
     
    7372
    7473        //Remove all viewports, so the added Viewport(camera) ist the only
    75         mRT->removeAllViewports();
    76         mRT->addViewport(camera);
     74        mRT_->removeAllViewports();
     75        mRT_->addViewport(camera);
    7776
    7877        //set the viewport settings
    79         Ogre::Viewport *vp = mRT->getViewport(0);
     78        Ogre::Viewport *vp = mRT_->getViewport(0);
    8079        vp->setClearEveryFrame(true);
    8180        vp->setOverlaysEnabled(false);
     
    8584
    8685        // we disable overlay rendering if it is set in config file and the viewport setting is enabled
    87         if(mDisableOverlays && enableOverlayFlag)
     86        if(mDisableOverlays_ && enableOverlayFlag)
    8887            GraphicsManager::getInstance().getViewport()->setOverlaysEnabled(false);
    8988
    90         if(mGridSize <= 1)
     89        if(mGridSize_ <= 1)
    9190        {
    9291            // Simple case where the contents of the screen are taken directly
    9392            // Also used when an invalid value is passed within gridSize (zero or negative grid size)
    94             mRT->update();    //render
     93            mRT_->update();    //render
    9594
    9695            //write the file on the Harddisk
    97             mRT->writeContentsToFile(fileName + "." + mFileExtension);
     96            mRT_->writeContentsToFile(fileName + "." + mFileExtension_);
    9897        }
    9998        else
     
    105104
    106105            // compute the Stepsize for the drid
    107             Ogre::Real frustumGridStepHorizontal  = (originalFrustumRight * 2) / mGridSize;
    108             Ogre::Real frustumGridStepVertical  = (originalFrustumTop * 2) / mGridSize;
     106            Ogre::Real frustumGridStepHorizontal  = (originalFrustumRight * 2) / mGridSize_;
     107            Ogre::Real frustumGridStepVertical  = (originalFrustumTop * 2) / mGridSize_;
    109108
    110109            // process each grid
    111110            Ogre::Real frustumLeft, frustumRight, frustumTop, frustumBottom;
    112             for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize * mGridSize; nbScreenshots++)
     111            for (unsigned int nbScreenshots = 0; nbScreenshots < mGridSize_ * mGridSize_; nbScreenshots++)
    113112            {
    114                 int y = nbScreenshots / mGridSize;
    115                 int x = nbScreenshots - y * mGridSize;
     113                int y = nbScreenshots / mGridSize_;
     114                int x = nbScreenshots - y * mGridSize_;
    116115
    117116                // Shoggoth frustum extents setting
     
    127126                // ignore time duration between frames
    128127                Ogre::Root::getSingletonPtr()->clearEventTimes();
    129                 mRT->update();    //render
     128                mRT_->update();    //render
    130129
    131130                //define the current
    132                 Ogre::Box subBox = Ogre::Box(x* mWindowWidth,y * mWindowHeight,x * mWindowWidth + mWindowWidth, y * mWindowHeight + mWindowHeight);
     131                Ogre::Box subBox = Ogre::Box(x* mWindowWidth_,y * mWindowHeight_,x * mWindowWidth_ + mWindowWidth_, y * mWindowHeight_ + mWindowHeight_);
    133132                //copy the content from the temp buffer into the final picture PixelBox
    134133                //Place the tempBuffer content at the right position
    135                 mBuffer->blitToMemory(mFinalPicturePB.getSubVolume(subBox));
     134                mBuffer_->blitToMemory(mFinalPicturePB_.getSubVolume(subBox));
    136135
    137136            }
     
    142141            Ogre::Image finalImage; //declare the final Image Object
    143142            //insert the PixelBox data into the Image Object
    144             finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB.data), mFinalPicturePB.getWidth(),mFinalPicturePB.getHeight(),Ogre::PF_B8G8R8);
     143            finalImage = finalImage.loadDynamicImage(static_cast<unsigned char*>(mFinalPicturePB_.data), mFinalPicturePB_.getWidth(), mFinalPicturePB_.getHeight(),Ogre::PF_B8G8R8);
    145144            // Save the Final image to a file
    146             finalImage.save(fileName + "." + mFileExtension);
     145            finalImage.save(fileName + "." + mFileExtension_);
    147146
    148147        }
     
    157156    }
    158157
     158    /**
     159    @brief
     160        Set the size of the grid.
     161    @param size
     162        The size of the grid.
     163    */
     164    void ScreenshotManager::setGridSize(unsigned int size)
     165    {
     166        if(size == this->mGridSize_)
     167            return;
     168
     169        this->mGridSize_ = size;
     170        // New PixelBox for the changed size.
     171        uint8_t* data_ = new uint8_t[(this->mWindowWidth_ * this->mGridSize_) * (this->mWindowHeight_ * this->mGridSize_) * 3];
     172        this->mFinalPicturePB_ = Ogre::PixelBox(this->mWindowWidth_ * this->mGridSize_, this->mWindowHeight_ * this->mGridSize_, 1, Ogre::PF_B8G8R8, data_);
     173    }
     174
     175    /**
     176    @brief
     177        Get a timestamp for the curent time instant.
     178    @return
     179        Returns a string with the timestamp.
     180    */
    159181    std::string ScreenshotManager::getTimestamp()
    160182    {
  • code/trunk/src/modules/designtools/ScreenshotManager.h

    r7163 r8079  
    2020{
    2121
    22 
    23     /* Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots.
    24     *  pRenderWindow:    Pointer to the render window.  This could be "mWindow" from the ExampleApplication,
    25     *              the window automatically created obtained when calling
    26     *              Ogre::Root::getSingletonPtr()->initialise(false) and retrieved by calling
    27     *              "Ogre::Root::getSingletonPtr()->getAutoCreatedWindow()", or the manually created
    28     *              window from calling "mRoot->createRenderWindow()".
    29     *  gridSize:      The magnification factor.  A 2 will create a 2x2 grid, doubling the size of the
    30                 screenshot.  A 3 will create a 3x3 grid, tripling the size of the screenshot.
    31     *  fileExtension:    The extension of the screenshot file name, hence the type of graphics file to generate.
    32     *              To generate "MyScreenshot.png" this parameter would contain ".png".
     22    /**
     23    @brief
     24        Class encapsulates Screenshot functionality and provides a method for making multi grid screenshots.
    3325    */
    3426    class ScreenshotManager : public OrxonoxClass, public Singleton<ScreenshotManager>
     
    3628        friend class Singleton<ScreenshotManager>;
    3729
    38     public:
    39         ScreenshotManager();
    40         ~ScreenshotManager();
     30        public:
     31            ScreenshotManager();
     32            virtual ~ScreenshotManager();
    4133
    42       /* Creates a screenshot with the given camera.
    43         * @param camera Pointer to the camera "looking at" the scene of interest
    44         * @param fileName the filename of the screenshot file.
    45       */
    46         void makeScreenshot() const;
     34            void makeScreenshot() const; //!< Creates a screenshot with the given camera.
    4735
    48         static void makeScreenshot_s()
    49             { getInstance().makeScreenshot(); }
     36            /**
     37            @brief Creates a screenshot with a given size.
     38            @param size Size is factor by which the current screen size is scaled.
     39            */
     40            static void makeScreenshot_s(unsigned int size)
     41                { getInstance().setGridSize(size); getInstance().makeScreenshot(); }
    5042
    51     protected:
    52         static std::string getTimestamp();
     43            void setGridSize(unsigned int size); //!< Set the size of the grid.
    5344
    54         std::string    mFileExtension;
    55         unsigned int   mGridSize, mWindowWidth, mWindowHeight;
    56         bool           mDisableOverlays;
    57         //temp texture with current screensize
    58         Ogre::TexturePtr mTempTex;
    59         Ogre::RenderTexture* mRT;
    60         Ogre::HardwarePixelBufferSharedPtr mBuffer;
    61         //PixelBox for a large Screenshot, if grid size is > 1
    62         Ogre::PixelBox  mFinalPicturePB;
    63         uint8_t* data_;
     45        protected:
     46            static std::string getTimestamp();
    6447
    65         static ScreenshotManager* singletonPtr_s;
     48            std::string mFileExtension_;
     49            unsigned int mGridSize_; //!< The magnification factor.  A 2 will create a 2x2 grid, doubling the size of the screenshot.  A 3 will create a 3x3 grid, tripling the size of the screenshot.
     50            unsigned int mWindowWidth_, mWindowHeight_;
     51            bool mDisableOverlays_;
     52            //! temp texture with current screensize
     53            Ogre::TexturePtr mTempTex_;
     54            Ogre::RenderTexture* mRT_;
     55            Ogre::HardwarePixelBufferSharedPtr mBuffer_;
     56            //! PixelBox for a large Screenshot, if grid size is > 1
     57            Ogre::PixelBox  mFinalPicturePB_;
     58            uint8_t* data_;
     59
     60            static ScreenshotManager* singletonPtr_s;
    6661    };
    6762
  • code/trunk/src/modules/designtools/SkyboxGenerator.cc

    r7284 r8079  
    5959
    6060        this->setConfigValues();
    61         takeScreenshot_ = false;
     61        this->takeScreenshot_ = false;
    6262        this->captionsRemoved_ = false;
    6363    }
  • code/trunk/src/modules/notifications/NotificationManager.cc

    r7552 r8079  
    103103    {
    104104        // Destroys all NotificationQueues that have been registered with the NotificationManager.
    105         for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++)
     105        std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin();
     106        while(it != this->queues_.end())
     107        {
    106108            it->second->destroy(true);
     109            it = this->queues_.begin();
     110        }
    107111
    108112        this->queues_.clear();
     
    298302        }
    299303
     304        COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl;
     305
    300306        // Remove the NotificationListener from the list of NotificationListeners.
    301307        this->listenerList_.erase(listener);
    302308        // Remove the Notifications list that was associated with the input NotificationListener.
    303309        this->notificationLists_.erase(identifier);
    304 
    305         COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
    306310    }
    307311
     
    361365    bool NotificationManager::registerQueue(NotificationQueue* queue)
    362366    {
     367        COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl;
    363368        return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
    364369    }
     
    372377    void NotificationManager::unregisterQueue(NotificationQueue* queue)
    373378    {
     379        COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl;
    374380        this->queues_.erase(queue->getName());
    375381    }
  • code/trunk/src/modules/notifications/NotificationQueue.cc

    r7489 r8079  
    137137            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    138138
     139        COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
     140
    139141        this->OrxonoxClass::destroy();
    140142    }
     
    167169            while(it != this->ordering_.upper_bound(&this->timeLimit_))
    168170            {
    169                 std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator temp = it;
    170                 it++;
    171                 this->remove(temp); // Remove the Notifications that have expired.
     171                this->remove(it); // Remove the Notifications that have expired.
     172                it = this->ordering_.begin();
    172173            }
    173174
     
    248249        if(GameMode::showsGraphics())
    249250            GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
     251
     252        COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
    250253    }
    251254
     
    259262        // Get all the NotificationContainers that were sent the same time the NotificationContainer we want to pop was sent.
    260263        std::pair<std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator, std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator> iterators = this->ordering_.equal_range(container);
     264
    261265        // Iterate through all suspects and remove the container as soon as we find it.
    262266        for(std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = iterators.first; it != iterators.second; it++)
     
    264268            if(container == *it)
    265269            {
     270                COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" popped from NotificationQueue '" << this->getName() << "'" << endl;
    266271                this->ordering_.erase(it);
    267272                break;
     
    290295        // Get the index at which the Notification is.
    291296        std::vector<NotificationContainer*>::difference_type index = it - this->notifications_.begin ();
     297
     298        COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" removed from NotificationQueue '" << this->getName() << "'" << endl;
     299
    292300        this->ordering_.erase(containerIterator);
    293301        this->notifications_.erase(it);
     
    310318    void NotificationQueue::clear(bool noGraphics)
    311319    {
     320        COUT(4) << "Clearing NotificationQueue " << this->getName() << "." << endl;
    312321        this->ordering_.clear();
    313322        // Delete all NotificationContainers in the list.
     
    372381    /**
    373382    @brief
    374         Produces all targets of the NotificationQueue concatinated as string, with kommas (',') as seperators.
     383        Produces all targets of the NotificationQueue concatinated as string, with commas (',') as seperators.
    375384    @return
    376385        Returns the targets as a string.
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r7601 r8079  
    5454
    5555        this->distance_ = 100.0f;
    56         this->targetName_ = BLANKSTRING;
     56        this->targetName_ = "";
    5757        this->singleTargetMode_ = false;
    5858    }
     
    181181    {
    182182        // If the targetname is no blank string single-target mode is enabled.
    183         if(targetname.compare(BLANKSTRING) != 0)
     183        if(targetname != "")
    184184            this->singleTargetMode_ = true;
    185185        else
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r7601 r8079  
    5050    this->distance_ = 100;
    5151    this->targetMask_.exclude(Class(BaseObject));
    52     this->targetName_ = BLANKSTRING;
     52    this->targetName_ = "";
    5353    this->singleTargetMode_ = false;
    5454  }
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.h

    r7601 r8079  
    7070
    7171      inline void setTargetName(const std::string& targetname)
    72         { if(targetname.compare(BLANKSTRING) != 0) this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
     72        { if(targetname != "") this->singleTargetMode_ = true; else this->singleTargetMode_ = false; this->targetName_ = targetname; }
    7373      inline const std::string& getTargetName(void)
    7474        { return this->targetName_; }
  • code/trunk/src/modules/overlays/OverlaysPrereqs.h

    r7655 r8079  
    8989    class KillMessage;
    9090    class LastManStandingInfos;
     91    class PauseNotice;
    9192    class TeamBaseMatchScore;
    9293    class UnderAttackHealthBar;
  • code/trunk/src/modules/overlays/hud/CMakeLists.txt

    r7655 r8079  
    1616  GametypeFadingMessage.cc
    1717  LastManStandingInfos.cc
     18  PauseNotice.cc
    1819)
  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    r7548 r8079  
    156156        {
    157157            COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
    158             if(this->spawnerTemplate_ == BLANKSTRING)
     158            if(this->spawnerTemplate_ == "")
    159159            {
    160160                COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
  • code/trunk/src/modules/questsystem/QuestItem.cc

    r7456 r8079  
    8787    void QuestItem::setId(const std::string & id)
    8888    {
    89         if(id.compare(BLANKSTRING) == 0) // Checks whether the id is a valid id.
     89        if(id == "") // Checks whether the id is a valid id.
    9090        {
    9191            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r7552 r8079  
    9191    /**
    9292    @brief
    93         Registers a Quest with the QuestManager to make it globally accessable.
     93        Registers a Quest with the QuestManager to make it globally accessible.
    9494        Uses it's id to make sure to be able to be identify and retrieve it later.
    9595    @param quest
     
    129129    /**
    130130    @brief
    131         Registers a QuestHint with the QuestManager to make it globally accessable.
     131        Registers a QuestHint with the QuestManager to make it globally accessible.
    132132        Uses it's id to make sure to be able to be identify and retrieve it later.
    133133    @param hint
     
    178178    Quest* QuestManager::findQuest(const std::string & questId)
    179179    {
    180         if(questId.compare(BLANKSTRING) == 1) // Check vor validity of the given id.
     180        if(questId == "") // Check for validity of the given id.
    181181            ThrowException(Argument, "Invalid questId.");
    182182
     
    207207    QuestHint* QuestManager::findHint(const std::string & hintId)
    208208    {
    209         if(hintId.compare(BLANKSTRING) == 1) // Check vor validity of the given id.
     209        if(hintId == "") // Check for validity of the given id.
    210210            ThrowException(Argument, "Invalid hintId.");
    211211
  • code/trunk/src/modules/questsystem/effects/AddQuestHint.cc

    r7552 r8079  
    8686    bool AddQuestHint::setHintId(const std::string & id)
    8787    {
    88         if(id.compare(BLANKSTRING) == 0)
     88        if(id == "")
    8989        {
    9090            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
  • code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc

    r7456 r8079  
    8181    bool ChangeQuestStatus::setQuestId(const std::string & id)
    8282    {
    83         if(id.compare(BLANKSTRING) == 0)
     83        if(id == "")
    8484        {
    8585            COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
  • code/trunk/src/orxonox/CameraManager.cc

    r7879 r8079  
    2929#include "CameraManager.h"
    3030
     31#include <cassert>
     32
    3133#include <OgreSceneManager.h>
    3234#include <OgreViewport.h>
    3335#include <OgreCompositorManager.h>
    3436
    35 #include "util/StringUtils.h"
    3637#include "util/ScopedSingletonManager.h"
    3738#include "core/GameMode.h"
    3839#include "core/GraphicsManager.h"
    39 #include "core/GUIManager.h"
    4040#include "core/ObjectList.h"
    4141#include "tools/Shader.h"
    4242#include "graphics/Camera.h"
    43 #include "Scene.h"
    4443
    4544namespace orxonox
     
    4847
    4948    CameraManager::CameraManager()
    50         : viewport_(GraphicsManager::getInstance().getViewport())
    5149    {
    5250        assert(GameMode::showsGraphics());
     
    5553    CameraManager::~CameraManager()
    5654    {
    57         GUIManager::getInstance().setCamera(0);
    5855    }
    5956
     
    9592            if (!this->cameraList_.empty())
    9693                this->cameraList_.front()->setFocus();
     94            else
     95                this->useCamera(NULL);
    9796        }
    9897        else
     
    102101    void CameraManager::useCamera(Ogre::Camera* camera)
    103102    {
    104         // This workaround is needed to avoid weird behaviour with active compositors while
    105         // switching the camera (like freezing the image)
    106         //
    107         // Last known Ogre version needing this workaround:
    108         // 1.4.8
    109         // 1.7.2
    110 
    111         // deactivate all compositors
    112         {
    113             Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();
    114             while (iterator.hasMoreElements())
    115                 Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false);
    116         }
    117 
    118         this->viewport_->setCamera(camera);
    119         GUIManager::getInstance().setCamera(camera);
    120 
    121         // reactivate all visible compositors
    122         {
    123             for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it)
    124                 it->updateVisibility();
    125         }
     103        GraphicsManager::getInstance().setCamera(camera);
    126104    }
    127105}
  • code/trunk/src/orxonox/CameraManager.h

    r6746 r8079  
    3838#include "OrxonoxPrereqs.h"
    3939
    40 #include <cassert>
    4140#include <list>
    4241#include "util/OgreForwardRefs.h"
    4342#include "util/Singleton.h"
    4443#include "core/OrxonoxClass.h"
    45 #include "core/SmartPtr.h"
    4644
    4745namespace orxonox
     
    6563
    6664            std::list<Camera*>    cameraList_;
    67             Ogre::Viewport*       viewport_;
    6865
    6966            static CameraManager* singletonPtr_s;
  • code/trunk/src/orxonox/ChatInputHandler.cc

    r7284 r8079  
    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
     
    7281    this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
    7382    this->inputState->setKeyHandler(this->inpbuf);
     83  }
     84
     85  ChatInputHandler::~ChatInputHandler()
     86  {
     87    /* Clean up */
     88    InputManager::getInstance().destroyState("chatinput");
     89    delete this->inpbuf;
    7490  }
    7591
     
    125141    // reds
    126142    for( i = 0; i < NumberOfColors/3; ++i )
    127     { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
    128       assert( this->text_colors[ i ] );
     143    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
    129144      green += 0.2f, blue += 0.2f;
    130145    }
     
    133148    red = 0.5, green = 1, blue = 0.5;
    134149    for( ; i < NumberOfColors*2/3; ++i )
    135     { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
    136       assert( this->text_colors[ i ] );
     150    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
    137151      red += 0.2f, blue += 0.2f;
    138152    }
     
    141155    red = 0.5, green = 0.5, blue = 1;
    142156    for( ; i < NumberOfColors; ++i )
    143     { this->text_colors[ i ] = new CEGUI::colour( red, green, blue );
    144       assert( this->text_colors[ i ] );
     157    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
    145158      red += 0.2f, green += 0.2f;
    146159    }
     
    196209
    197210    /* set the color according to the hash */
    198     tocolor->setTextColours( *(this->text_colors[ hash ]) );
     211    tocolor->setTextColours( this->text_colors[ hash ] );
    199212  }
    200213
  • code/trunk/src/orxonox/ChatInputHandler.h

    r7163 r8079  
    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>
     36#include <CEGUIcolour.h>
    3937
    40 /* project includes */
    41 #include <OrxonoxPrereqs.h>
    42 #include <core/BaseObject.h>
    43 #include <core/PathConfig.h>
    44 
    45 #include "core/input/InputBuffer.h"
    46 #include "core/input/InputManager.h"
    47 #include "core/input/InputState.h"
    48 
    49 #include <network/ChatListener.h>
    50 #include <PlayerManager.h>
    51 #include <infos/PlayerInfo.h>
    52 
    53 #include "../libraries/network/Host.h"
    54 #include <util/Singleton.h>
     38#include "util/Singleton.h"
     39#include "network/ChatListener.h"
    5540
    5641namespace orxonox // tolua_export
     
    7055      /* colors for nickname coloring */
    7156      static const int NumberOfColors = 10;
    72       CEGUI::colour *text_colors[ NumberOfColors ];
     57      CEGUI::colour text_colors[ NumberOfColors ];
    7358
    7459      /** input state */
     
    11095      /** constructor */
    11196      ChatInputHandler();
     97      ~ChatInputHandler();
    11298      friend class Singleton<ChatInputHandler>;
    11399
  • code/trunk/src/orxonox/LevelInfo.h

    r7804 r8079  
    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/trunk/src/orxonox/LevelManager.cc

    r7839 r8079  
    7575    LevelManager::~LevelManager()
    7676    {
     77        // Delete all the LevelInfoItem objects because the LevelManager created them
     78        std::set<LevelInfoItem*, LevelInfoCompare>::iterator it = availableLevels_.begin();
     79        for (; it != availableLevels_.end(); ++it)
     80            delete *it;
    7781    }
    7882
     
    237241    void LevelManager::compileAvailableLevelList()
    238242    {
     243        // Get all files matching the level criteria
    239244        Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
    240         // Iterate over all *.oxw level files.
     245
     246        // We only want to load as little as possible
     247        ClassTreeMask mask;
     248        mask.exclude(Class(BaseObject));
     249        mask.include(Class(LevelInfo));
     250
     251        // Iterate over all the found *.oxw files
    241252        COUT(3) << "Loading LevelInfos..." << std::endl;
     253        std::set<std::string> names;
    242254        for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
    243255        {
    244             //TODO: Replace with tag?
     256            // TODO: Replace with tag?
    245257            if (it->find("old/") != 0)
    246258            {
    247                 size_t pos = it->find(".oxw");
     259                LevelInfoItem* info = NULL;
    248260
    249261                // Load the LevelInfo object from the level file.
    250                 bool infoExists = false;
    251262                XMLFile file = XMLFile(*it);
    252                 ClassTreeMask mask = ClassTreeMask();
    253                 mask.exclude(ClassIdentifier<BaseObject>::getIdentifier());
    254                 mask.include(ClassIdentifier<LevelInfo>::getIdentifier());
    255                 Loader::load(&file, mask, false);
    256                 // Iterate over all LevelInfos.
     263                Loader::load(&file, mask, false, true);
     264
     265                // Find the LevelInfo object we've just loaded (if there was one)
    257266                for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)
     267                    if(item->getXMLFilename() == *it)
     268                        info = item->copy();
     269
     270                // We don't need the loaded stuff anymore
     271                Loader::unload(&file);
     272
     273                if(info == NULL)
    258274                {
    259                     LevelInfoItem* info = item->copy();
    260                     if(info->getXMLFilename() == *it) // If the LevelInfo for this level exists we insert it into the list of available levels.
    261                     {
    262                         this->availableLevels_.insert(info);
    263                         infoExists = true;
    264                     }
     275                    // Create a default LevelInfoItem object that merely contains the name
     276                    std::string filenameWOExtension = it->substr(0, it->find(".oxw"));
     277                    info = new LevelInfoItem(filenameWOExtension, *it);
    265278                }
    266                 Loader::unload(&file, mask);
    267                 if(!infoExists) // If the LevelInfo for this level doesn't exist, we create a new one and insert it into the list of available levels.
    268                     this->availableLevels_.insert(new LevelInfoItem(it->substr(0, pos), *it));
     279
     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
     284                // Warn about multiple items so that it gets fixed quickly
     285                if(availableLevels_.find(info) != availableLevels_.end())
     286                {
     287                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl;
     288                    // Delete LevelInfoItem to avoid a dangling pointer
     289                    delete info;
     290                }
     291                else
     292                    this->availableLevels_.insert(info);
    269293            }
    270294        }
  • code/trunk/src/orxonox/LevelManager.h

    r7804 r8079  
    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/trunk/src/orxonox/controllers/HumanController.cc

    r7863 r8079  
    6161    SetConsoleCommand("HumanController", "cycleNavigationFocus",   &HumanController::cycleNavigationFocus).addShortcut();
    6262    SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut();
     63    SetConsoleCommand("HumanController", "myposition",             &HumanController::myposition    ).addShortcut();
    6364
    6465    CreateUnloadableFactory(HumanController);
     
    200201    void HumanController::toggleGodMode()
    201202    {
    202         HumanController::getLocalControllerSingleton()->setGodMode( !HumanController::getLocalControllerSingleton()->getGodMode() );
     203        if (HumanController::localController_s)
     204            HumanController::localController_s->setGodMode(!HumanController::localController_s->getGodMode());
     205    }
     206
     207    void HumanController::myposition()
     208    {
     209        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     210        {
     211            const Vector3& position = HumanController::localController_s->controllableEntity_->getPosition();
     212            const Quaternion& orientation = HumanController::localController_s->controllableEntity_->getOrientation();
     213
     214            COUT(0) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" ";
     215            COUT(0) << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << std::endl;
     216        }
    203217    }
    204218
  • code/trunk/src/orxonox/controllers/HumanController.h

    r7533 r8079  
    7373            static void suicide();
    7474            static void toggleGodMode();
     75            static void myposition();
    7576
    7677            static void addBots(unsigned int amount);
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r7879 r8079  
    4646#include "LevelManager.h"
    4747#include "PlayerManager.h"
     48#include "GSRoot.h"
    4849
    4950namespace orxonox
     
    5556
    5657    SetConsoleCommand(__CC_startMainMenu_name, &GSLevel::startMainMenu).deactivate();
    57     SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues(BLANKSTRING).deactivate();
     58    SetConsoleCommand(__CC_changeGame_name, &GSLevel::changeGame).defaultValues("").deactivate();
    5859
    5960    GSLevel::GSLevel(const GameStateInfo& info)
     
    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
     
    202205    /*static*/ void GSLevel::changeGame(const std::string& level)
    203206    {
    204         if(level != BLANKSTRING)
     207        if(level != "")
    205208            LevelManager::getInstance().setDefaultLevel(level);
    206209
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r7876 r8079  
    5757    static const std::string __CC_setMainMenuSoundPath_name = "setMMSoundPath";
    5858
    59     SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).defaultValues(BLANKSTRING).deactivate();
    60     SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).defaultValues(BLANKSTRING).deactivate();
    61     SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).defaultValues(BLANKSTRING).deactivate();
    62     SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).defaultValues(BLANKSTRING).deactivate();
     59    SetConsoleCommand(__CC_startStandalone_name,      &GSMainMenu::startStandalone).defaultValues("").deactivate();
     60    SetConsoleCommand(__CC_startServer_name,          &GSMainMenu::startServer    ).defaultValues("").deactivate();
     61    SetConsoleCommand(__CC_startClient_name,          &GSMainMenu::startClient    ).defaultValues("").deactivate();
     62    SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).defaultValues("").deactivate();
    6363    SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
    6464
     
    9696    {
    9797        // show main menu
     98        GraphicsManager::getInstance().setCamera(this->camera_);
    9899        GUIManager::getInstance().showGUI("MainMenu", true);
    99         GUIManager::getInstance().setCamera(this->camera_);
    100100        GUIManager::getInstance().setBackgroundImage("MainMenuBackground", "Background");
    101         GraphicsManager::getInstance().setCamera(this->camera_);
    102101
    103102        InputManager::getInstance().enterState("MainMenuHackery");
     
    129128        InputManager::getInstance().leaveState("MainMenuHackery");
    130129
    131         GUIManager::getInstance().setCamera(0);
     130        GraphicsManager::getInstance().setCamera(0);
    132131        GUIManager::getInstance().setBackgroundImage("");
    133132        GUIManager::hideGUI("MainMenu");
    134         GraphicsManager::getInstance().setCamera(0);
    135133
    136134        ModifyConsoleCommand(__CC_startStandalone_name).deactivate();
     
    178176    void GSMainMenu::startStandalone(const std::string& level)
    179177    {
    180         if(level != BLANKSTRING)
     178        if(level != "")
    181179            LevelManager::getInstance().setDefaultLevel(level);
    182180
     
    194192    void GSMainMenu::startServer(const std::string& level)
    195193    {
    196         if(level != BLANKSTRING)
     194        if(level != "")
    197195            LevelManager::getInstance().setDefaultLevel(level);
    198196
     
    210208    void GSMainMenu::startClient(const std::string& destination)
    211209    {
    212         if(destination != BLANKSTRING)
     210        if(destination != "")
    213211            Client::getInstance()->setDestination(destination, NETWORK_PORT);
    214212
     
    226224    void GSMainMenu::startDedicated(const std::string& level)
    227225    {
    228         if(level != BLANKSTRING)
     226        if(level != "")
    229227            LevelManager::getInstance().setDefaultLevel(level);
    230228
  • code/trunk/src/orxonox/gamestates/GSMainMenu.h

    r7876 r8079  
    5353        void setMainMenuSoundPath(const std::string& path);
    5454
    55         static void startStandalone(const std::string& level = BLANKSTRING); //!< Start a level in standalone mode.
    56         static void startServer(const std::string& level = BLANKSTRING); //!< Start a level in server mode.
    57         static void startClient(const std::string& destination = BLANKSTRING); //!< Connect to a game as client.
    58         static void startDedicated(const std::string& level = BLANKSTRING); //!< Start a level in dedicated mode.
     55        static void startStandalone(const std::string& level = ""); //!< Start a level in standalone mode.
     56        static void startServer(const std::string& level = ""); //!< Start a level in server mode.
     57        static void startClient(const std::string& destination = ""); //!< Connect to a game as client.
     58        static void startDedicated(const std::string& level = ""); //!< Start a level in dedicated mode.
    5959        static void startIOConsole();
    6060
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r7284 r8079  
    3838#include "tools/interfaces/Tickable.h"
    3939
     40#include "GSLevel.h"
     41
    4042namespace orxonox
    4143{
     
    4345
    4446    static const std::string __CC_setTimeFactor_name = "setTimeFactor";
     47    static const std::string __CC_setPause_name = "setPause";
    4548    static const std::string __CC_pause_name = "pause";
     49
     50    /*static*/ bool GSRoot::startMainMenu_s = false;
    4651
    4752    SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
    4853    SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0);
     54    SetConsoleCommand(__CC_setPause_name,      &GSRoot::setPause     ).accessLevel(AccessLevel::Master).hide();
    4955    SetConsoleCommand(__CC_pause_name,         &GSRoot::pause        ).accessLevel(AccessLevel::Master);
    5056
     
    8389
    8490        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this);
     91        ModifyConsoleCommand(__CC_setPause_name).setObject(this);
    8592        ModifyConsoleCommand(__CC_pause_name).setObject(this);
    8693    }
     
    8996    {
    9097        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0);
     98        ModifyConsoleCommand(__CC_setPause_name).setObject(0);
    9199        ModifyConsoleCommand(__CC_pause_name).setObject(0);
    92100    }
     
    94102    void GSRoot::update(const Clock& time)
    95103    {
     104        if(startMainMenu_s)
     105        {
     106            delayedStartMainMenu();
     107            startMainMenu_s = false;
     108        }
     109
    96110        for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; )
    97111        {
     
    157171    }
    158172
     173    void GSRoot::setPause(bool pause)
     174    {
     175        if (GameMode::isMaster())
     176        {
     177            if (pause != this->bPaused_)
     178                this->pause();
     179        }
     180    }
     181
    159182    void GSRoot::changedTimeFactor(float factor_new, float factor_old)
    160183    {
     
    162185            callStaticNetworkFunction(&TimeFactorListener::setTimeFactor, CLIENTID_UNKNOWN, factor_new);
    163186    }
     187
     188    /*static*/ void GSRoot::delayedStartMainMenu(void)
     189    {
     190        if(!startMainMenu_s)
     191            startMainMenu_s = true;
     192        else
     193            GSLevel::startMainMenu();
     194    }
     195
    164196}
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r7172 r8079  
    5151        // when taking the function address.
    5252        void setTimeFactor(float factor);
     53        void setPause(bool pause);
    5354        void pause();
     55
     56        static void delayedStartMainMenu(void);
    5457
    5558    protected:
     
    5962        bool                  bPaused_;
    6063        float                 timeFactorPauseBackup_;
     64        static bool           startMainMenu_s;
    6165    };
    6266}
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r7801 r8079  
    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/trunk/src/orxonox/graphics/Camera.cc

    r7163 r8079  
    6969        this->bHasFocus_ = false;
    7070        this->bDrag_ = false;
    71         this->nearClipDistance_ = 1;
    7271        this->lastDtLagged_ = false;
    7372
     
    7574
    7675        this->setConfigValues();
     76
     77        this->configvaluecallback_changedFovAndAspectRatio();
    7778        this->configvaluecallback_changedNearClipDistance();
    7879    }
     
    8283        if (this->isInitialized())
    8384        {
    84             if (GUIManager::getInstance().getCamera() == this->camera_)
    85                 GUIManager::getInstance().setCamera(NULL);
    8685            this->releaseFocus();
    8786
     
    9998    void Camera::setConfigValues()
    10099    {
    101         SetConfigValue(nearClipDistance_, 1.0f).callback(this, &Camera::configvaluecallback_changedNearClipDistance);
     100        SetConfigValue(fov_, 80.0f)
     101            .description("Horizontal field of view in degrees")
     102            .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio);
     103        SetConfigValue(aspectRatio_, 1.0f)
     104            .description("Aspect ratio of pixels (width / height)")
     105            .callback(this, &Camera::configvaluecallback_changedFovAndAspectRatio);
     106        SetConfigValue(nearClipDistance_, 1.0f)
     107            .description("Distance from the camera where close objects will be clipped")
     108            .callback(this, &Camera::configvaluecallback_changedNearClipDistance);
     109    }
     110
     111    /**
     112        @brief Update FOV and the aspect ratio of the camera after the config values or the window's size have changed.
     113    */
     114    void Camera::configvaluecallback_changedFovAndAspectRatio()
     115    {
     116        // the aspect ratio of the window (width / height) has to be multiplied with the pixels aspect ratio (this->aspectRatio_)
     117        float aspectRatio = this->aspectRatio_ * this->getWindowWidth() / this->getWindowHeight();
     118        this->camera_->setAspectRatio(aspectRatio);
     119
     120        // Since we use horizontal FOV, we have to calculate FOVy by dividing by the aspect ratio and using some tangents
     121        Radian fovy(2 * atan(tan(Degree(this->fov_).valueRadians() / 2) / aspectRatio));
     122        this->camera_->setFOVy(fovy);
    102123    }
    103124
     
    105126    {
    106127        this->camera_->setNearClipDistance(this->nearClipDistance_);
     128    }
     129
     130    /**
     131        @brief Inherited from WindowEventListener.
     132    */
     133    void Camera::windowResized(unsigned int newWidth, unsigned int newHeight)
     134    {
     135        this->configvaluecallback_changedFovAndAspectRatio();
    107136    }
    108137
  • code/trunk/src/orxonox/graphics/Camera.h

    r6417 r8079  
    3333
    3434#include "util/OgreForwardRefs.h"
     35#include "core/WindowEventListener.h"
    3536#include "tools/interfaces/Tickable.h"
    3637#include "tools/interfaces/TimeFactorListener.h"
     
    3940namespace orxonox
    4041{
    41     class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener
     42    class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener
    4243    {
    4344        friend class CameraManager;
     
    6667            void removeFocus();
    6768            void setFocus();
     69
     70            void configvaluecallback_changedFovAndAspectRatio();
    6871            void configvaluecallback_changedNearClipDistance();
     72
     73            void windowResized(unsigned int newWidth, unsigned int newHeight);
    6974
    7075            Ogre::Camera*    camera_;
     
    7479            bool             bDrag_;
    7580            bool             lastDtLagged_;
     81            float            fov_;
     82            float            aspectRatio_;
    7683    };
    7784}
  • code/trunk/src/orxonox/graphics/GlobalShader.cc

    r5781 r8079  
    6161        SUPER(GlobalShader, XMLPort, xmlelement, mode);
    6262
    63         XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositor, getCompositor, xmlelement, mode);
     63        XMLPortParamExtern(GlobalShader, Shader, &this->shader_, "compositor", setCompositorName, getCompositorName, xmlelement, mode);
    6464    }
    6565
     
    6767    {
    6868        registerVariable(this->bVisible_,                                         VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
    69         registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
     69        registerVariable(const_cast<std::string&>(this->shader_.getCompositorName()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositorName));
    7070    }
    7171
  • code/trunk/src/orxonox/graphics/GlobalShader.h

    r7163 r8079  
    5353        private:
    5454            void registerVariables();
    55             void changedCompositor();
    5655
    5756            Shader shader_;
  • code/trunk/src/orxonox/graphics/Model.cc

    r7183 r8079  
    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/trunk/src/orxonox/items/Engine.cc

    r7547 r8079  
    102102    void Engine::setConfigValues()
    103103    {
    104         SetConfigValue(blurStrength_, 3.0f);
     104        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
     105            .description("Enable or disable the motion blur effect when moving very fast")
     106            .callback(this, &Engine::changedEnableMotionBlur);
     107        SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
     108            .description("Defines the strength of the motion blur effect");
    105109    }
    106110
     
    204208        this->ship_->setSteeringDirection(Vector3::ZERO);
    205209
    206         if (!this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
     210        if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
    207211        {
    208212            this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
    209             this->boostBlur_->setCompositor("Radial Blur");
     213            this->boostBlur_->setCompositorName("Radial Blur");
    210214        }
    211215
    212216        if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    213             this->boostBlur_->setParameter("Ogre/Compositor/Radial_Blur", 0, 0, "sampleStrength", this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f));
     217        {
     218            float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f);
     219
     220            this->boostBlur_->setVisible(blur > 0);
     221            this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     222        }
    214223    }
    215224
     
    257266        return this->ship_->getWorldPosition();
    258267    }
     268
     269    void Engine::changedEnableMotionBlur()
     270    {
     271        if (!this->bEnableMotionBlur_)
     272        {
     273            this->boostBlur_->destroy();
     274            this->boostBlur_ = 0;
     275        }
     276    }
    259277}
  • code/trunk/src/orxonox/items/Engine.h

    r7552 r8079  
    127127            void registerVariables();
    128128            void networkcallback_shipID();
     129            void changedEnableMotionBlur();
    129130
    130131            SpaceShip* ship_;
     
    150151            Shader* boostBlur_;
    151152            float blurStrength_;
     153            bool bEnableMotionBlur_;
    152154    };
    153155}
  • code/trunk/src/orxonox/overlays/InGameConsole.cc

    r7689 r8079  
    6060    const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
    6161
    62     SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole).addShortcut();
    63     SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole).addShortcut();
     62    SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
     63    SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
    6464
    6565    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
  • code/trunk/src/orxonox/sound/AmbientSound.cc

    r7856 r8079  
    2929#include "AmbientSound.h"
    3030
     31#include "core/CoreIncludes.h"
    3132#include "core/GameMode.h"
    3233#include "core/Resource.h"
     
    3839        : bPlayOnLoad_(false)
    3940    {
     41        RegisterObject(AmbientSound);
     42
    4043        // Ambient sounds always fade in
    4144        this->setVolume(0);
Note: See TracChangeset for help on using the changeset viewer.