mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-22 23:06:18 +00:00
Reduce warning count
This commit is contained in:
parent
e01cb5694b
commit
a28a4733c4
4 changed files with 146 additions and 145 deletions
|
|
@ -90,7 +90,7 @@ raiseRbExc(const Exception &exc);
|
||||||
template<rb_data_type_t *rbType>
|
template<rb_data_type_t *rbType>
|
||||||
static VALUE classAllocate(VALUE klass)
|
static VALUE classAllocate(VALUE klass)
|
||||||
{
|
{
|
||||||
return rb_data_typed_object_alloc(klass, 0, rbType);
|
return rb_data_typed_object_wrap(klass, 0, rbType);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class C>
|
template<class C>
|
||||||
|
|
|
||||||
|
|
@ -283,7 +283,7 @@ void EventThread::process(RGSSThreadData &rtData)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
if (rtData.inputText.length() < rtData.inputTextLimit) rtData.inputText += event.text.text;
|
if (rtData.inputText.length() < (size_t)(rtData.inputTextLimit)) rtData.inputText += event.text.text;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_KEYDOWN :
|
case SDL_KEYDOWN :
|
||||||
|
|
|
||||||
283
src/oneshot.cpp
283
src/oneshot.cpp
|
|
@ -68,148 +68,148 @@
|
||||||
GTK_RESPONSE_APPLY = -10,
|
GTK_RESPONSE_APPLY = -10,
|
||||||
GTK_RESPONSE_HELP = -11
|
GTK_RESPONSE_HELP = -11
|
||||||
} GtkResponseType;
|
} GtkResponseType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xdg_user_dir_lookup_with_fallback:
|
||||||
|
* @type: a string specifying the type of directory
|
||||||
|
* @fallback: value to use if the directory isn't specified by the user
|
||||||
|
* @returns: a newly allocated absolute pathname
|
||||||
|
*
|
||||||
|
* Looks up a XDG user directory of the specified type.
|
||||||
|
* Example of types are "DESKTOP" and "DOWNLOAD".
|
||||||
|
*
|
||||||
|
* In case the user hasn't specified any directory for the specified
|
||||||
|
* type the value returned is @fallback.
|
||||||
|
*
|
||||||
|
* The return value is newly allocated and must be freed with
|
||||||
|
* free(). The return value is never NULL if @fallback != NULL, unless
|
||||||
|
* out of memory.
|
||||||
|
**/
|
||||||
|
static char *
|
||||||
|
xdg_user_dir_lookup_with_fallback (const char *type, const char *fallback)
|
||||||
|
{
|
||||||
|
FILE *file;
|
||||||
|
char *home_dir, *config_home, *config_file;
|
||||||
|
char buffer[512];
|
||||||
|
char *user_dir;
|
||||||
|
char *p, *d;
|
||||||
|
int len;
|
||||||
|
int relative;
|
||||||
|
|
||||||
|
home_dir = getenv ("HOME");
|
||||||
|
|
||||||
|
if (home_dir == NULL)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
config_home = getenv ("XDG_CONFIG_HOME");
|
||||||
|
if (config_home == NULL || config_home[0] == 0)
|
||||||
|
{
|
||||||
|
config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
|
||||||
|
if (config_file == NULL)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
strcpy (config_file, home_dir);
|
||||||
|
strcat (config_file, "/.config/user-dirs.dirs");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
|
||||||
|
if (config_file == NULL)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
strcpy (config_file, config_home);
|
||||||
|
strcat (config_file, "/user-dirs.dirs");
|
||||||
|
}
|
||||||
|
|
||||||
|
file = fopen (config_file, "r");
|
||||||
|
free (config_file);
|
||||||
|
if (file == NULL)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
user_dir = NULL;
|
||||||
|
while (fgets (buffer, sizeof (buffer), file))
|
||||||
|
{
|
||||||
|
/* Remove newline at end */
|
||||||
|
len = strlen (buffer);
|
||||||
|
if (len > 0 && buffer[len-1] == '\n')
|
||||||
|
buffer[len-1] = 0;
|
||||||
|
|
||||||
|
p = buffer;
|
||||||
|
while (*p == ' ' || *p == '\t')
|
||||||
|
p++;
|
||||||
|
|
||||||
|
if (strncmp (p, "XDG_", 4) != 0)
|
||||||
|
continue;
|
||||||
|
p += 4;
|
||||||
|
if (strncmp (p, type, strlen (type)) != 0)
|
||||||
|
continue;
|
||||||
|
p += strlen (type);
|
||||||
|
if (strncmp (p, "_DIR", 4) != 0)
|
||||||
|
continue;
|
||||||
|
p += 4;
|
||||||
|
|
||||||
|
while (*p == ' ' || *p == '\t')
|
||||||
|
p++;
|
||||||
|
|
||||||
|
if (*p != '=')
|
||||||
|
continue;
|
||||||
|
p++;
|
||||||
|
|
||||||
|
while (*p == ' ' || *p == '\t')
|
||||||
|
p++;
|
||||||
|
|
||||||
|
if (*p != '"')
|
||||||
|
continue;
|
||||||
|
p++;
|
||||||
|
|
||||||
|
relative = 0;
|
||||||
|
if (strncmp (p, "$HOME/", 6) == 0)
|
||||||
|
{
|
||||||
|
p += 6;
|
||||||
|
relative = 1;
|
||||||
|
}
|
||||||
|
else if (*p != '/')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (relative)
|
||||||
|
{
|
||||||
|
user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
|
||||||
|
if (user_dir == NULL)
|
||||||
|
goto error2;
|
||||||
|
|
||||||
|
strcpy (user_dir, home_dir);
|
||||||
|
strcat (user_dir, "/");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
user_dir = (char*) malloc (strlen (p) + 1);
|
||||||
|
if (user_dir == NULL)
|
||||||
|
goto error2;
|
||||||
|
|
||||||
|
*user_dir = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
d = user_dir + strlen (user_dir);
|
||||||
|
while (*p && *p != '"')
|
||||||
|
{
|
||||||
|
if ((*p == '\\') && (*(p+1) != 0))
|
||||||
|
p++;
|
||||||
|
*d++ = *p++;
|
||||||
|
}
|
||||||
|
*d = 0;
|
||||||
|
}
|
||||||
|
error2:
|
||||||
|
fclose (file);
|
||||||
|
|
||||||
|
if (user_dir)
|
||||||
|
return user_dir;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (fallback)
|
||||||
|
return strdup (fallback);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* xdg_user_dir_lookup_with_fallback:
|
|
||||||
* @type: a string specifying the type of directory
|
|
||||||
* @fallback: value to use if the directory isn't specified by the user
|
|
||||||
* @returns: a newly allocated absolute pathname
|
|
||||||
*
|
|
||||||
* Looks up a XDG user directory of the specified type.
|
|
||||||
* Example of types are "DESKTOP" and "DOWNLOAD".
|
|
||||||
*
|
|
||||||
* In case the user hasn't specified any directory for the specified
|
|
||||||
* type the value returned is @fallback.
|
|
||||||
*
|
|
||||||
* The return value is newly allocated and must be freed with
|
|
||||||
* free(). The return value is never NULL if @fallback != NULL, unless
|
|
||||||
* out of memory.
|
|
||||||
**/
|
|
||||||
static char *
|
|
||||||
xdg_user_dir_lookup_with_fallback (const char *type, const char *fallback)
|
|
||||||
{
|
|
||||||
FILE *file;
|
|
||||||
char *home_dir, *config_home, *config_file;
|
|
||||||
char buffer[512];
|
|
||||||
char *user_dir;
|
|
||||||
char *p, *d;
|
|
||||||
int len;
|
|
||||||
int relative;
|
|
||||||
|
|
||||||
home_dir = getenv ("HOME");
|
|
||||||
|
|
||||||
if (home_dir == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
config_home = getenv ("XDG_CONFIG_HOME");
|
|
||||||
if (config_home == NULL || config_home[0] == 0)
|
|
||||||
{
|
|
||||||
config_file = (char*) malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
|
|
||||||
if (config_file == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
strcpy (config_file, home_dir);
|
|
||||||
strcat (config_file, "/.config/user-dirs.dirs");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
config_file = (char*) malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
|
|
||||||
if (config_file == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
strcpy (config_file, config_home);
|
|
||||||
strcat (config_file, "/user-dirs.dirs");
|
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen (config_file, "r");
|
|
||||||
free (config_file);
|
|
||||||
if (file == NULL)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
user_dir = NULL;
|
|
||||||
while (fgets (buffer, sizeof (buffer), file))
|
|
||||||
{
|
|
||||||
/* Remove newline at end */
|
|
||||||
len = strlen (buffer);
|
|
||||||
if (len > 0 && buffer[len-1] == '\n')
|
|
||||||
buffer[len-1] = 0;
|
|
||||||
|
|
||||||
p = buffer;
|
|
||||||
while (*p == ' ' || *p == '\t')
|
|
||||||
p++;
|
|
||||||
|
|
||||||
if (strncmp (p, "XDG_", 4) != 0)
|
|
||||||
continue;
|
|
||||||
p += 4;
|
|
||||||
if (strncmp (p, type, strlen (type)) != 0)
|
|
||||||
continue;
|
|
||||||
p += strlen (type);
|
|
||||||
if (strncmp (p, "_DIR", 4) != 0)
|
|
||||||
continue;
|
|
||||||
p += 4;
|
|
||||||
|
|
||||||
while (*p == ' ' || *p == '\t')
|
|
||||||
p++;
|
|
||||||
|
|
||||||
if (*p != '=')
|
|
||||||
continue;
|
|
||||||
p++;
|
|
||||||
|
|
||||||
while (*p == ' ' || *p == '\t')
|
|
||||||
p++;
|
|
||||||
|
|
||||||
if (*p != '"')
|
|
||||||
continue;
|
|
||||||
p++;
|
|
||||||
|
|
||||||
relative = 0;
|
|
||||||
if (strncmp (p, "$HOME/", 6) == 0)
|
|
||||||
{
|
|
||||||
p += 6;
|
|
||||||
relative = 1;
|
|
||||||
}
|
|
||||||
else if (*p != '/')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (relative)
|
|
||||||
{
|
|
||||||
user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
|
|
||||||
if (user_dir == NULL)
|
|
||||||
goto error2;
|
|
||||||
|
|
||||||
strcpy (user_dir, home_dir);
|
|
||||||
strcat (user_dir, "/");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
user_dir = (char*) malloc (strlen (p) + 1);
|
|
||||||
if (user_dir == NULL)
|
|
||||||
goto error2;
|
|
||||||
|
|
||||||
*user_dir = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
d = user_dir + strlen (user_dir);
|
|
||||||
while (*p && *p != '"')
|
|
||||||
{
|
|
||||||
if ((*p == '\\') && (*(p+1) != 0))
|
|
||||||
p++;
|
|
||||||
*d++ = *p++;
|
|
||||||
}
|
|
||||||
*d = 0;
|
|
||||||
}
|
|
||||||
error2:
|
|
||||||
fclose (file);
|
|
||||||
|
|
||||||
if (user_dir)
|
|
||||||
return user_dir;
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (fallback)
|
|
||||||
return strdup (fallback);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
#error "Operating system not detected."
|
#error "Operating system not detected."
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -949,6 +949,7 @@ std::string Oneshot::textinput(const char* prompt, int char_limit, const char* f
|
||||||
// gInputTextTexture.loadFromRenderedText(threadData.inputText.c_str(), textColor, gRenderer, gFont);
|
// gInputTextTexture.loadFromRenderedText(threadData.inputText.c_str(), textColor, gRenderer, gFont);
|
||||||
|
|
||||||
std::vector<std::string> *fontNames = new std::vector<std::string>();
|
std::vector<std::string> *fontNames = new std::vector<std::string>();
|
||||||
|
fontNames->push_back(fontName);
|
||||||
fontNames->push_back("VL Gothic");
|
fontNames->push_back("VL Gothic");
|
||||||
Font *font = new Font(fontNames, 18);
|
Font *font = new Font(fontNames, 18);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1099,8 +1099,8 @@ SettingsMenu::SettingsMenu(RGSSThreadData &rtData)
|
||||||
const int bWidgetH = 64;
|
const int bWidgetH = 64;
|
||||||
const int bWidgetY = winSize.y - layoutH*bWidgetH - 48;
|
const int bWidgetY = winSize.y - layoutH*bWidgetH - 48;
|
||||||
|
|
||||||
for (int y = 0; y < layoutH; ++y)
|
for (int y = 0; y < (int)(layoutH); ++y)
|
||||||
for (int x = 0; x < layoutW; ++x)
|
for (int x = 0; x < (int)(layoutW); ++x)
|
||||||
{
|
{
|
||||||
int i = x*layoutH+y;
|
int i = x*layoutH+y;
|
||||||
BindingWidget w(i, p, IntRect(x*bWidgetW, bWidgetY+y*bWidgetH,
|
BindingWidget w(i, p, IntRect(x*bWidgetW, bWidgetY+y*bWidgetH,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue