Changeset 132

Show
Ignore:
Timestamp:
08/26/10 18:14:55 (18 months ago)
Author:
Carsten
Message:
  • Updated the Video Settings dialog of the Main Menu GUI to show the list of video modes that are actually available on the current system.
  • Replaced the initial Cafu console to buffer all messages until they can be copied to the in-game console, so that e.g. Main Menu GUI init errors don't get lost.
Location:
cafu/branches/cafu_to_wx
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • cafu/branches/cafu_to_wx/Ca3DE/AppCafu.cpp

    r131 r132  
    2727#include "ClipSys/CollisionModelMan_impl.hpp" 
    2828#include "ConsoleCommands/ConsoleInterpreterImpl.hpp" 
    29 #include "ConsoleCommands/ConsoleStdout.hpp" 
     29#include "ConsoleCommands/ConsoleStringBuffer.hpp" 
    3030#include "ConsoleCommands/ConVar.hpp" 
    3131#include "ConsoleCommands/ConFunc.hpp" 
     
    4848// For each interface that is globally available to the application, 
    4949// provide a definition for the pointer instance and have it point to an implementation. 
    50 static cf::ConsoleStdoutT ConsoleStdout; 
    51 cf::ConsoleI* Console=&ConsoleStdout; 
    52  
    53 // static cf::ConsoleFileT ConsoleFile("info.log"); 
     50static cf::ConsoleStringBufferT ConsoleStringBuffer; 
     51cf::ConsoleI* Console=&ConsoleStringBuffer; 
     52 
     53// static cf::ConsoleFileT ConsoleFile("console.log"); 
    5454// cf::ConsoleI* Console=&ConsoleFile; 
    5555 
     
    203203                wxString::Format("        %i x %i at any color depth and refresh rate,\n", VideoMode3.w, VideoMode3.h)+ 
    204204                "but it didn't work out (zero values mean system defaults).\n"+ 
    205                 "We will use the currently active video mode instead and continue.\n\n"+ 
     205                "We will continue with the currently active video mode instead, where you can press F11 to toggle full-screen mode.\n\n"+ 
    206206                "Alternatively, you can set a different video mode at the Options menu,\n"+ 
    207207                "or tweak the video mode details via the console variables.\n", 
  • cafu/branches/cafu_to_wx/Ca3DE/ConDefs.cpp

    r130 r132  
    6262/*static*/ ConVarT Options_ClientRemoteName        ("dlg_clRemoteName", "192.168.1.1", ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "Name or IP of the server the client connects to."); 
    6363/*static*/ ConVarT Options_ClientRemotePortNr      ("dlg_clRemotePort",         30000, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "Port number of the remote server.", 0, 0xFFFF); 
    64 /*static*/ ConVarT Options_ClientDisplayBPP        ("dlg_clDisplayBPP",            32, ConVarT::FLAG_MAIN_EXE,                            "The display depth in bits-per-pixel. Normally use 32, or 0 for system default.", 0, 64); 
    65 /*static*/ ConVarT Options_ClientDisplayRefresh    ("dlg_clDisplayRefresh",         0, ConVarT::FLAG_MAIN_EXE,                            "The display refresh rate. Use 0 for system default, check with your monitor specs for any other value."); 
     64/*static*/ ConVarT Options_ClientDisplayBPP        ("dlg_clDisplayBPP",            32, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "The display depth in bits-per-pixel. Normally use 32, or 0 for system default.", 0, 64); 
     65/*static*/ ConVarT Options_ClientDisplayRefresh    ("dlg_clDisplayRefresh",         0, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "The display refresh rate. Use 0 for system default, check with your monitor specs for any other value."); 
    6666/*static*/ ConVarT Options_ClientTextureDetail     ("dlg_clTextureDetail",          0, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "0 high detail, 1 medium detail, 2 low detail", 0, 2); 
    6767/*static*/ ConVarT Options_ServerGameName          ("dlg_svGameName",    "DeathMatch", ConVarT::FLAG_MAIN_EXE,                            "Name of the game (MOD) to load."); 
  • cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.cpp

    r131 r132  
    3333#include "ConsoleCommands/Console.hpp" 
    3434#include "ConsoleCommands/ConsoleInterpreter.hpp" 
     35#include "ConsoleCommands/ConsoleStringBuffer.hpp" 
    3536#include "ConsoleCommands/ConVar.hpp" 
    3637#include "GuiSys/ConsoleByWindow.hpp" 
     
    438439    m_PrevConsole=Console; 
    439440    Console=m_ConByGuiWin; 
     441 
     442    // Copy the output to the previous console to the now current console. 
     443    cf::ConsoleStringBufferT* ConsoleSB=dynamic_cast<cf::ConsoleStringBufferT*>(m_PrevConsole); 
     444    if (ConsoleSB) Console->Print(ConsoleSB->GetBuffer()); 
    440445 
    441446    m_InitState=INIT_SUCCESS; 
  • cafu/branches/cafu_to_wx/Games/DeathMatch/GUIs/MainMenu/MainMenu_main.cgui

    r36 r132  
    1919 
    2020    return ""; 
     21end 
     22 
     23-- Parses a string that describes a video mode. It returns the width, height, colour depth and refresh rate. 
     24function ParseModeStr(ModeStr) 
     25    -- For case-insensitive matching, translate the entire string to lower case. 
     26    ModeStr=ModeStr:lower(); 
     27 
     28    local width, height=ModeStr:match("(%d+)%s*x%s*(%d+)"); 
     29    local bpp          =ModeStr:match("(%d+)%s*bpp"); 
     30    local rate         =ModeStr:match("(%d+)%s*hz"); 
     31 
     32    if width  then width =tonumber(width);  end 
     33    if height then height=tonumber(height); end 
     34    if bpp    then bpp   =tonumber(bpp);    end 
     35    if rate   then rate  =tonumber(rate);   end 
     36 
     37    return width, height, bpp, rate; 
    2138end 
    2239 
     
    544561 
    545562function OptionsContextMenu.Frame.Video:OnMouseButtonUp() 
    546     -- Select the first screen resolution that is at least as wide as "dlg_clWindowSizeX" (1024*768 is used as a fall-back). 
    547     VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(2);   -- Safety if the loop below fails for some reason. 
     563    -- Select the screen resolution that matches the one specified in the console variables. 
     564    VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(0);   -- Safety if the loop below fails for some reason. 
    548565 
    549566    for ModeNr=0, VideoOptionsDialog.Frame.ScreenResChoice:GetNumChoices()-1 do 
    550         local ResX=tonumber(VideoOptionsDialog.Frame.ScreenResChoice:GetChoice(ModeNr):match("%d+")); 
    551  
    552         if (ResX>=ci.GetValue("dlg_clWindowSizeX")) then 
     567        local width, height, bpp, rate=ParseModeStr(VideoOptionsDialog.Frame.ScreenResChoice:GetChoice(ModeNr)); 
     568 
     569        if width==ci.GetValue("dlg_clWindowSizeX") and height==ci.GetValue("dlg_clWindowSizeY") then 
     570            -- The width and height match, select this mode. 
    553571            VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(ModeNr); 
    554             break; 
     572 
     573            if bpp==ci.GetValue("dlg_clDisplayBPP") and rate==ci.GetValue("dlg_clDisplayRefresh") then 
     574                -- The color depth and refresh rate match, too - stop looking for a better match. 
     575                break; 
     576            end 
    555577        end 
    556578    end 
     
    11601182-- Move into OnInit()? 
    11611183VideoOptionsDialog.Frame.ScreenResChoice:Clear(); 
    1162 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 640 x 480"); 
    1163 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 800 x 600"); 
    1164 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1024 x 768"); 
    1165 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1152 x 864"); 
    1166 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1280 x 1024"); 
    1167 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1600 x 1200"); 
    1168 VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(2);   -- Set again when the dialog is shown. 
     1184 
     1185-- For each video mode in console variable "VideoModes" (a multi-line string with one 
     1186-- video mode per line, separated by new-lines), append a choice to the choice window. 
     1187for ModeStr in ci.GetValue("VideoModes"):gmatch("[^\n]+") do 
     1188    VideoOptionsDialog.Frame.ScreenResChoice:Append(" "..ModeStr); 
     1189end 
     1190 
     1191-- It is possible (though normally not necessary) to add custom video modes here, 
     1192-- for example when your favorite video mode is not automatically detected and provided above. 
     1193-- There is no guarantee though that the graphics driver can set any custom modes 
     1194-- (or else the mode had been automatically included in the enumeration above). 
     1195-- Examples: 
     1196-- VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1152 x 864"); 
     1197-- VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1440 x 900, 32 bpp, 60 Hz"); 
     1198 
     1199-- The list of video modes above should never be totally empty, 
     1200-- but still just handle the case here to be totally sure. 
     1201if (VideoOptionsDialog.Frame.ScreenResChoice:GetNumChoices()==0) then 
     1202    Console.Warning("Console variable VideoModes is empty!"); 
     1203 
     1204    VideoOptionsDialog.Frame.ScreenResChoice:Append(" 640 x 480"); 
     1205    VideoOptionsDialog.Frame.ScreenResChoice:Append(" 800 x 600"); 
     1206    VideoOptionsDialog.Frame.ScreenResChoice:Append(" 1024 x 768"); 
     1207end 
     1208 
     1209VideoOptionsDialog.Frame.ScreenResChoice:SetSelection(0);   -- Set again when the dialog is shown. 
    11691210 
    11701211function VideoOptionsDialog.Frame.ScreenResChoice:OnSelectionChanged(SelNum) 
     
    12151256    local ModeStr=VideoOptionsDialog.Frame.ScreenResChoice:GetChoice(ModeNr); 
    12161257 
    1217     local ResX, ResY=ModeStr:match("(%d+)%s*x%s*(%d+)"); 
    1218  
    1219     ci.SetValue("dlg_clWindowSizeX",   ResX); 
    1220     ci.SetValue("dlg_clWindowSizeY",   ResY); 
     1258    local width, height, bpp, rate=ParseModeStr(ModeStr); 
     1259 
     1260    if width  then ci.SetValue("dlg_clWindowSizeX",    width ); end 
     1261    if height then ci.SetValue("dlg_clWindowSizeY",    height); end 
     1262    if bpp    then ci.SetValue("dlg_clDisplayBPP",     bpp   ); end 
     1263    if rate   then ci.SetValue("dlg_clDisplayRefresh", rate  ); end 
     1264 
    12211265    ci.SetValue("dlg_clFullScreen",    VideoOptionsDialog.Frame.FullScreenChoice:GetSelection()==1); 
    12221266    ci.SetValue("dlg_clTextureDetail", VideoOptionsDialog.Frame.TextureDetailChoice:GetSelection());