forked from Mirrors/openclonk
Add a dialogue for windows which can be displayed when the graphics engine initialisation failed
The dialogue has fields for resolution and a checkbox for fullscreen moderope
parent
7251865981
commit
cb6eb060cc
|
@ -324,6 +324,8 @@ set(OC_CLONK_SOURCES
|
|||
src/gui/C4GameOptions.h
|
||||
src/gui/C4GameOverDlg.cpp
|
||||
src/gui/C4GameOverDlg.h
|
||||
src/gui/C4GfxErrorDlg.cpp
|
||||
src/gui/C4GfxErrorDlg.h
|
||||
src/gui/C4GuiButton.cpp
|
||||
src/gui/C4GuiCheckBox.cpp
|
||||
src/gui/C4GuiComboBox.cpp
|
||||
|
|
|
@ -38,6 +38,7 @@ IDS_BTN_RELOAD=&Aktualisieren
|
|||
IDS_BTN_RENAME=Umbenennen
|
||||
IDS_BTN_RESETCONFIG=Konfiguration zurücksetzen
|
||||
IDS_BTN_RESETKEYBOARD=Alle zurücksetzen
|
||||
IDS_BTN_RESTART=Neu &Starten
|
||||
IDS_BTN_RETRY=Wiederholen
|
||||
IDS_BTN_SIMPLE=<- Einfach
|
||||
IDS_BTN_START=Starten
|
||||
|
@ -784,6 +785,9 @@ IDS_MSG_FREEVIEW=Freie Sicht
|
|||
IDS_MSG_FULLSCREEN=Vollbild
|
||||
IDS_MSG_FULLSCREEN_DESC=Vollbildmodus aktivieren.
|
||||
IDS_MSG_GFXENGINE_DESC=Gibt an, welcher Grafikmodus benutzt wird. Änderungen greifen erst beim nächsten Programmstart.
|
||||
IDS_MSG_GFXERR_RESINVAL=Ungültige Auflösung!
|
||||
IDS_MSG_GFXERR_RESNOTFOUND=Die gewählte Auflösung wird vom System anscheinend nicht unterstützt.
|
||||
IDS_MSG_GFXERR_TXT=OpenClonk konnte OpenGL nicht laden. Prüfen Sie, ob Ihr Grafiktreiber aktuell ist und OpenGL 1.3 unterstützt.
|
||||
IDS_MSG_HASDISCONNECTED=%s hat die Verbindung beendet (%s).
|
||||
IDS_MSG_HASJOINEDTHECHANNEL=%s ist dem Chat-Kanal beigetreten.
|
||||
IDS_MSG_HASLEFTTHECHANNEL=%s hat den Chat-Kanal verlassen (%s)
|
||||
|
|
|
@ -38,6 +38,7 @@ IDS_BTN_RELOAD=Reloa&d
|
|||
IDS_BTN_RENAME=Rename
|
||||
IDS_BTN_RESETCONFIG=Reset configuration
|
||||
IDS_BTN_RESETKEYBOARD=Reset all
|
||||
IDS_BTN_RESTART=Restart
|
||||
IDS_BTN_RETRY=Retry
|
||||
IDS_BTN_SIMPLE=<- Basic
|
||||
IDS_BTN_START=Start
|
||||
|
@ -783,6 +784,9 @@ IDS_MSG_FREEVIEW=free view
|
|||
IDS_MSG_FULLSCREEN=Fullscreen
|
||||
IDS_MSG_FULLSCREEN_DESC=Use fullscreen mode.
|
||||
IDS_MSG_GFXENGINE_DESC=Determines the rendering engine. Changes take effect when the game is restarted.
|
||||
IDS_MSG_GFXERR_RESINVAL=Invalid resolution!
|
||||
IDS_MSG_GFXERR_RESNOTFOUND=This resolution is probably not supportet by your system.
|
||||
IDS_MSG_GFXERR_TXT=OpenClonk could not load OpenGL. Please check if your graphics card driver is up-to-date and supports OpenGL 1.3.
|
||||
IDS_MSG_HASDISCONNECTED=%s has disconnected (%s).
|
||||
IDS_MSG_HASJOINEDTHECHANNEL=%s has joined the channel.
|
||||
IDS_MSG_HASLEFTTHECHANNEL=%s has left the channel (%s)
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
|
||||
#include <getopt.h>
|
||||
|
||||
#include <C4GfxErrorDlg.h>
|
||||
|
||||
static C4Network2IRCClient ApplicationIRCClient;
|
||||
|
||||
C4Application::C4Application():
|
||||
|
@ -161,7 +163,7 @@ bool C4Application::DoInit(int argc, char * argv[])
|
|||
if (!isEditor)
|
||||
{
|
||||
if (!(pWindow = FullScreen.Init(this)))
|
||||
{ Clear(); return false; }
|
||||
{ Clear(); ShowGfxErrorDialog(); return false; }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2012, Julius Michaelis
|
||||
*
|
||||
* Portions might be copyrighted by other authors who have contributed
|
||||
* to OpenClonk.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
* See isc_license.txt for full license and disclaimer.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
/* Functions for displaying a settings dialogue to users when the graphics system failed */
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <C4Include.h>
|
||||
#include <resource.h>
|
||||
#include <C4Version.h>
|
||||
#include <C4Application.h>
|
||||
#include <C4windowswrapper.h>
|
||||
#include <C4GfxErrorDlg.h>
|
||||
|
||||
static int edittext_toi(HWND hWnd, int field)
|
||||
{
|
||||
WCHAR buf[512]; buf[511] = 0;
|
||||
GetDlgItemTextW(hWnd,field,buf,509);
|
||||
StdStrBuf data(buf);
|
||||
const char* bufp = data.getData();
|
||||
while(*bufp == ' ') ++bufp;
|
||||
int res = strtol(bufp, NULL, 0);
|
||||
if(errno != ERANGE)
|
||||
return res;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static INT_PTR CALLBACK GfxErrProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(Msg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
// Set Icon, Caption and static Texts
|
||||
SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(Application.GetInstance(),MAKEINTRESOURCE(IDI_00_C4X)));
|
||||
SendMessage(hWnd,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(Application.GetInstance(),MAKEINTRESOURCE(IDI_00_C4X)));
|
||||
SetWindowTextW(hWnd, GetWideChar(C4ENGINECAPTION));
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_MSG ,GetWideChar(LoadResStr("IDS_MSG_GFXERR_TXT")));
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_RES ,GetWideChar(LoadResStr("IDS_CTL_RESOLUTION")));
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_FSCRN,GetWideChar(LoadResStr("IDS_MSG_FULLSCREEN")));
|
||||
SetDlgItemTextW(hWnd,IDCANCEL ,GetWideChar(LoadResStr("IDS_DLG_EXIT")));
|
||||
SetDlgItemTextW(hWnd,IDOK ,GetWideChar(LoadResStr("IDS_BTN_RESTART")));
|
||||
// Set Options
|
||||
SendMessage(GetDlgItem(hWnd, IDC_GFXERR_FSCRN), BM_SETCHECK, Config.Graphics.Windowed?0:1, 0);
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_XINP ,FormatString("%d",Config.Graphics.ResX).GetWideChar());
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_YINP ,FormatString("%d",Config.Graphics.ResY).GetWideChar());
|
||||
return TRUE;
|
||||
|
||||
case WM_DESTROY:
|
||||
EndDialog(hWnd,1);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case IDCANCEL:
|
||||
EndDialog(hWnd,1);
|
||||
return TRUE;
|
||||
case IDC_GFXERR_FSCRN:
|
||||
case IDC_GFXERR_XINP:
|
||||
case IDC_GFXERR_YINP:
|
||||
{ // Handle Resolution values
|
||||
if(SendMessage(GetDlgItem(hWnd, IDC_GFXERR_FSCRN),BM_GETCHECK,0,0) == BST_CHECKED)
|
||||
{
|
||||
int resx = edittext_toi(hWnd,IDC_GFXERR_XINP);
|
||||
int resy = edittext_toi(hWnd,IDC_GFXERR_YINP);
|
||||
if(resx < 1 || resy < 1) // res. will be 0 if the user supplies an invalid value
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_INVAL,GetWideChar(LoadResStr("IDS_MSG_GFXERR_RESINVAL")));
|
||||
else
|
||||
{
|
||||
// Check if res is in list of supportet
|
||||
bool found = false;
|
||||
int32_t idx = 0, iXRes, iYRes, iBitDepth;
|
||||
while (Application.GetIndexedDisplayMode(idx++, &iXRes, &iYRes, &iBitDepth, NULL, Config.Graphics.Monitor))
|
||||
if (iBitDepth == Config.Graphics.BitDepth)
|
||||
if(iXRes == resx && iYRes == resy)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_INVAL,found?L"":GetWideChar(LoadResStr("IDS_MSG_GFXERR_RESNOTFOUND")));
|
||||
}
|
||||
}
|
||||
else
|
||||
SetDlgItemTextW(hWnd,IDC_GFXERR_INVAL,L"");
|
||||
return TRUE;
|
||||
}
|
||||
case IDOK:
|
||||
{
|
||||
int resx = edittext_toi(hWnd,IDC_GFXERR_XINP);
|
||||
int resy = edittext_toi(hWnd,IDC_GFXERR_YINP);
|
||||
if(resx < 1 || resy < 1) break;
|
||||
Config.Graphics.Windowed = !(SendMessage(GetDlgItem(hWnd, IDC_GFXERR_FSCRN),BM_GETCHECK,0,0) == BST_CHECKED);
|
||||
Config.Graphics.ResX = resx;
|
||||
Config.Graphics.ResY = resy;
|
||||
Config.Save();
|
||||
TCHAR selfpath[4096];
|
||||
GetModuleFileName(NULL, selfpath, 4096);
|
||||
STARTUPINFOW siStartupInfo;
|
||||
PROCESS_INFORMATION piProcessInfo;
|
||||
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
|
||||
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
|
||||
siStartupInfo.cb = sizeof(siStartupInfo);
|
||||
CreateProcessW(selfpath, L"",
|
||||
NULL, NULL, FALSE, 0, NULL, Config.General.ExePath.GetWideChar(), &siStartupInfo, &piProcessInfo);
|
||||
EndDialog(hWnd,2);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void ShowGfxErrorDialog()
|
||||
{
|
||||
int ret = DialogBox(Application.GetInstance(), MAKEINTRESOURCE(IDD_GFXERROR), NULL, GfxErrProcedure);
|
||||
if (ret == 0 || ret == -1)
|
||||
{
|
||||
LPVOID lpMsgBuf;
|
||||
DWORD err = GetLastError();
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
err,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0, NULL );
|
||||
LogF("Error in GfxErrorDlg: %d - %s", err, StdStrBuf((wchar_t*)lpMsgBuf).getData());
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
void ShowGfxErrorDialog(){} // To be implemented? It's mainly a windows (users') problem.
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* This file is ineligible for copyright and therefore in the public domain,
|
||||
* because it does not reach the required threshold of originality.
|
||||
*
|
||||
* "Clonk" is a registered trademark of Matthes Bender.
|
||||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
void ShowGfxErrorDialog();
|
|
@ -167,6 +167,24 @@ BEGIN
|
|||
ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
|
||||
END
|
||||
|
||||
IDD_GFXERROR DIALOGEX 200, 200, 300, 200
|
||||
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
|
||||
WS_SYSMENU | DS_CENTER
|
||||
CAPTION "OCOGLERR"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x1
|
||||
BEGIN
|
||||
LTEXT "ERRORMSGGFX",IDC_GFXERR_MSG,6,20,294,33
|
||||
LTEXT "RES",IDC_GFXERR_RES,40,72,100,11
|
||||
LTEXT "X:",IDC_GFXERR_X,100,86,20,11
|
||||
EDITTEXT IDC_GFXERR_XINP,120,85,35,13, ES_RIGHT | WS_TABSTOP
|
||||
LTEXT "Y:",IDC_GFXERR_Y,100,100,20,11
|
||||
EDITTEXT IDC_GFXERR_YINP,120,99,35,13, ES_RIGHT | WS_TABSTOP
|
||||
LTEXT "INVAL",IDC_GFXERR_INVAL,170,86,110,33
|
||||
AUTOCHECKBOX "FULLSCREEN",IDC_GFXERR_FSCRN, 40, 135, 100, 11, WS_TABSTOP
|
||||
DEFPUSHBUTTON "RESTART",IDOK, 180,174,60,14, WS_TABSTOP
|
||||
PUSHBUTTON "CANCEL",IDCANCEL,60,174,60,14, WS_TABSTOP
|
||||
END
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
|
|
|
@ -54,10 +54,19 @@
|
|||
#define IDC_STATICSCRIPT 2026
|
||||
#define IDC_STATICTEXTURE 2027
|
||||
#define IDC_STATICTIME 2028
|
||||
#define IDC_GFXERR_MSG 2029
|
||||
#define IDC_GFXERR_RES 2030
|
||||
#define IDC_GFXERR_X 2031
|
||||
#define IDC_GFXERR_XINP 2032
|
||||
#define IDC_GFXERR_Y 2033
|
||||
#define IDC_GFXERR_YINP 2034
|
||||
#define IDC_GFXERR_FSCRN 2035
|
||||
#define IDC_GFXERR_INVAL 2036
|
||||
#define IDD_COMPONENT 3000
|
||||
#define IDD_CONSOLE 3001
|
||||
#define IDD_PROPERTIES 3002
|
||||
#define IDD_TOOLS 3003
|
||||
#define IDD_GFXERROR 3004
|
||||
#define IDI_00_C4X 4000
|
||||
#define IDI_01_OCS 4001
|
||||
#define IDI_02_OCG 4002
|
||||
|
|
Loading…
Reference in New Issue