mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
Remove needless code; fix KWin compositor disabling; enable GTK dialogs on XFCE
This commit is contained in:
parent
474bb2ce30
commit
c8b0b92513
4 changed files with 17 additions and 34 deletions
13
src/i18n.cpp
13
src/i18n.cpp
|
|
@ -2,7 +2,6 @@
|
|||
Really hacked-together naiive implementation of gettext
|
||||
*/
|
||||
#include "i18n.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -16,16 +15,13 @@ int family = LOCALE_FAMILY_LATIN;
|
|||
size_t readSize;
|
||||
|
||||
int getLocaleFamily() {
|
||||
Debug() << "Get family:" << family;
|
||||
return family;
|
||||
}
|
||||
|
||||
const char* findtext(unsigned int msgid, const char* fallback) {
|
||||
Debug() << "Looking for msg" << msgid << fallback;
|
||||
if (msgid >= nStr) {
|
||||
return fallback;
|
||||
} else {
|
||||
Debug() << "found" << strdict[msgid];
|
||||
return strdict[msgid];
|
||||
}
|
||||
}
|
||||
|
|
@ -52,12 +48,10 @@ void _setLocaleFamily(const char* locale) {
|
|||
void _read(void * ptr, size_t size, size_t count, FILE * stream) {
|
||||
readSize = fread(ptr, size, count, stream);
|
||||
if (readSize != count) {
|
||||
Debug() << "Short read in i18n!";
|
||||
}
|
||||
}
|
||||
|
||||
void loadLocale(const char* locale) {
|
||||
Debug() << "Load locale:" << locale;
|
||||
char pathbuf[100];
|
||||
FILE* locfile;
|
||||
char header[8];
|
||||
|
|
@ -73,18 +67,17 @@ void loadLocale(const char* locale) {
|
|||
if (locfile) {
|
||||
_read(header, 1, 8, locfile);
|
||||
if (!strcmp(header, LOC_HEADER)) {
|
||||
//read number of strs in this file
|
||||
// Read number of strs in this file
|
||||
_read(&nStr, 4, 1, locfile);
|
||||
strdict = (char**)malloc(sizeof(char*) * nStr);
|
||||
for (i = 0; i < nStr; i++) {
|
||||
//read the size of the next string
|
||||
// Read the size of the next string
|
||||
_read(&strSize, 4, 1, locfile);
|
||||
strdict[i] = (char*)malloc(strSize+1);
|
||||
if (strSize > 0) {
|
||||
//read the contents of the next string
|
||||
// Read the contents of the next string
|
||||
_read(strdict[i], 1, strSize, locfile);
|
||||
strdict[i][strSize] = 0;
|
||||
Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize;
|
||||
}
|
||||
strdict[i][strSize] = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ int main(int argc, char *argv[])
|
|||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0");
|
||||
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "1");
|
||||
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
||||
|
||||
/* initialize SDL first */
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) < 0)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
#include <SDL2/SDL_image.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
|
||||
//OS-Specific code
|
||||
// OS-Specific code
|
||||
#if defined _WIN32
|
||||
#define OS_W32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
|
@ -296,6 +296,7 @@ Oneshot::Oneshot(RGSSThreadData &threadData) :
|
|||
gtk_init(0, 0);
|
||||
} else if (desktop.find("xfce") != std::string::npos) {
|
||||
desktopEnv = "xfce";
|
||||
gtk_init(0, 0);
|
||||
} else if (desktop.find("kde") != std::string::npos) {
|
||||
desktopEnv = "kde";
|
||||
} else if (desktop.find("lxde") != std::string::npos) {
|
||||
|
|
@ -477,7 +478,12 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
|
|||
if (!title)
|
||||
title = "";
|
||||
#if defined OS_LINUX
|
||||
if (desktopEnv == "gnome" || desktopEnv == "mate" || desktopEnv == "cinnamon") {
|
||||
if (
|
||||
desktopEnv == "gnome" ||
|
||||
desktopEnv == "mate" ||
|
||||
desktopEnv == "cinnamon" ||
|
||||
desktopEnv == "xfce"
|
||||
) {
|
||||
linux_DialogData data = {type, body, title, 0};
|
||||
gdk_threads_add_idle(linux_dialog, &data);
|
||||
gtk_main();
|
||||
|
|
@ -485,16 +491,15 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
|
|||
}
|
||||
#endif
|
||||
|
||||
//SDL message box
|
||||
|
||||
//Button data
|
||||
// SDL message box
|
||||
// Button data
|
||||
static const SDL_MessageBoxButtonData buttonOk = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "OK"};
|
||||
static const SDL_MessageBoxButtonData buttonsOk[] = {buttonOk};
|
||||
SDL_MessageBoxButtonData buttonYes = {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, p->txtYes.c_str()};
|
||||
SDL_MessageBoxButtonData buttonNo = {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, p->txtNo.c_str()};
|
||||
SDL_MessageBoxButtonData buttonsYesNo[] = {buttonNo, buttonYes};
|
||||
|
||||
//Messagebox data
|
||||
// Messagebox data
|
||||
SDL_MessageBoxData data;
|
||||
data.window = NULL;//p->window;
|
||||
data.colorScheme = 0;
|
||||
|
|
@ -529,7 +534,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
|
|||
break;
|
||||
}
|
||||
|
||||
//Set buttons
|
||||
// Set buttons
|
||||
switch (type)
|
||||
{
|
||||
case MSG_INFO:
|
||||
|
|
@ -545,7 +550,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
|
|||
break;
|
||||
}
|
||||
|
||||
//Show messagebox
|
||||
// Show messagebox
|
||||
#ifdef OS_W32
|
||||
PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC);
|
||||
#endif
|
||||
|
|
@ -586,20 +591,6 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f
|
|||
// Disable text input
|
||||
SDL_StopTextInput();
|
||||
|
||||
// //Free loaded images
|
||||
// gPromptTextTexture.free();
|
||||
// gInputTextTexture.free();
|
||||
|
||||
// //Free global font
|
||||
// TTF_CloseFont(gFont);
|
||||
// gFont = NULL;
|
||||
|
||||
// //Destroy renderer
|
||||
// SDL_DestroyRenderer(gRenderer);
|
||||
// gRenderer = NULL;
|
||||
// delete promptBmp;
|
||||
// delete inputBmp;
|
||||
|
||||
return threadData.inputText;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include "util.h"
|
||||
#include "sharedstate.h"
|
||||
#include "i18n.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
|
|
@ -539,7 +538,6 @@ struct SettingsMenuPrivate
|
|||
int x, int y, int alignW,
|
||||
Justification just, SDL_Color c, bool bold = false)
|
||||
{
|
||||
Debug() << "draw text:" << str;
|
||||
SDL_Surface *txt = createTextSurface(str, c, bold);
|
||||
if (txt) {
|
||||
blitTextSurf(surf, x, y, alignW, txt, just);
|
||||
|
|
|
|||
Loading…
Reference in a new issue