mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-06 23:15:42 +02:00
Start working on ScreenResizer
This commit is contained in:
parent
88cdb903fa
commit
fd248709e3
2 changed files with 283 additions and 279 deletions
|
@ -1,23 +1,23 @@
|
||||||
/*
|
/*
|
||||||
** graphics-binding.cpp
|
** graphics-binding.cpp
|
||||||
**
|
**
|
||||||
** This file is part of mkxp.
|
** This file is part of mkxp.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||||
**
|
**
|
||||||
** mkxp is free software: you can redistribute it and/or modify
|
** mkxp is free software: you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
** the Free Software Foundation, either version 2 of the License, or
|
** the Free Software Foundation, either version 2 of the License, or
|
||||||
** (at your option) any later version.
|
** (at your option) any later version.
|
||||||
**
|
**
|
||||||
** mkxp is distributed in the hope that it will be useful,
|
** mkxp is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
** GNU General Public License for more details.
|
** GNU General Public License for more details.
|
||||||
**
|
**
|
||||||
** You should have received a copy of the GNU General Public License
|
** You should have received a copy of the GNU General Public License
|
||||||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
|
@ -68,34 +68,34 @@ RB_METHOD(graphicsFrameReset)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEF_GRA_PROP_I(PropName) \
|
#define DEF_GRA_PROP_I(PropName) \
|
||||||
RB_METHOD(graphics##Get##PropName) \
|
RB_METHOD(graphics##Get##PropName) \
|
||||||
{ \
|
{ \
|
||||||
RB_UNUSED_PARAM; \
|
RB_UNUSED_PARAM; \
|
||||||
return rb_fix_new(shState->graphics().get##PropName()); \
|
return rb_fix_new(shState->graphics().get##PropName()); \
|
||||||
} \
|
} \
|
||||||
RB_METHOD(graphics##Set##PropName) \
|
RB_METHOD(graphics##Set##PropName) \
|
||||||
{ \
|
{ \
|
||||||
RB_UNUSED_PARAM; \
|
RB_UNUSED_PARAM; \
|
||||||
int value; \
|
int value; \
|
||||||
rb_get_args(argc, argv, "i", &value RB_ARG_END); \
|
rb_get_args(argc, argv, "i", &value RB_ARG_END); \
|
||||||
shState->graphics().set##PropName(value); \
|
shState->graphics().set##PropName(value); \
|
||||||
return rb_fix_new(value); \
|
return rb_fix_new(value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DEF_GRA_PROP_B(PropName) \
|
#define DEF_GRA_PROP_B(PropName) \
|
||||||
RB_METHOD(graphics##Get##PropName) \
|
RB_METHOD(graphics##Get##PropName) \
|
||||||
{ \
|
{ \
|
||||||
RB_UNUSED_PARAM; \
|
RB_UNUSED_PARAM; \
|
||||||
return rb_bool_new(shState->graphics().get##PropName()); \
|
return rb_bool_new(shState->graphics().get##PropName()); \
|
||||||
} \
|
} \
|
||||||
RB_METHOD(graphics##Set##PropName) \
|
RB_METHOD(graphics##Set##PropName) \
|
||||||
{ \
|
{ \
|
||||||
RB_UNUSED_PARAM; \
|
RB_UNUSED_PARAM; \
|
||||||
bool value; \
|
bool value; \
|
||||||
rb_get_args(argc, argv, "b", &value RB_ARG_END); \
|
rb_get_args(argc, argv, "b", &value RB_ARG_END); \
|
||||||
shState->graphics().set##PropName(value); \
|
shState->graphics().set##PropName(value); \
|
||||||
return rb_bool_new(value); \
|
return rb_bool_new(value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_METHOD(graphicsWidth)
|
RB_METHOD(graphicsWidth)
|
||||||
{
|
{
|
||||||
|
@ -204,8 +204,8 @@ DEF_GRA_PROP_B(ShowCursor)
|
||||||
|
|
||||||
#define INIT_GRA_PROP_BIND(PropName, prop_name_s) \
|
#define INIT_GRA_PROP_BIND(PropName, prop_name_s) \
|
||||||
{ \
|
{ \
|
||||||
_rb_define_module_function(module, prop_name_s, graphics##Get##PropName); \
|
_rb_define_module_function(module, prop_name_s, graphics##Get##PropName); \
|
||||||
_rb_define_module_function(module, prop_name_s "=", graphics##Set##PropName); \
|
_rb_define_module_function(module, prop_name_s "=", graphics##Set##PropName); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void graphicsBindingInit()
|
void graphicsBindingInit()
|
||||||
|
@ -221,9 +221,10 @@ void graphicsBindingInit()
|
||||||
|
|
||||||
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
|
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
|
||||||
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
|
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
|
||||||
|
#ifndef USE_ESSENTIALS_FIXES
|
||||||
if (rgssVer >= 2)
|
if (rgssVer >= 2)
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
_rb_define_module_function(module, "width", graphicsWidth);
|
_rb_define_module_function(module, "width", graphicsWidth);
|
||||||
_rb_define_module_function(module, "height", graphicsHeight);
|
_rb_define_module_function(module, "height", graphicsHeight);
|
||||||
_rb_define_module_function(module, "wait", graphicsWait);
|
_rb_define_module_function(module, "wait", graphicsWait);
|
||||||
|
@ -233,7 +234,9 @@ void graphicsBindingInit()
|
||||||
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
|
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
|
||||||
|
|
||||||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||||
|
#ifndef USE_ESSENTIALS_FIXES
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (rgssVer >= 3)
|
if (rgssVer >= 3)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
|
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
|
||||||
#include <SDL_syswm.h>
|
|
||||||
#include "sharedstate.h"
|
#include "sharedstate.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -188,36 +187,32 @@ MiniFFI_call(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
|
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
|
||||||
// On Windows, if essentials fixes are enabled, function calls that
|
// On Windows, if essentials fixes are enabled, function calls that
|
||||||
// do not work with MKXP will be intercepted here so that the code
|
// do not work with MKXP will be intercepted here so that the code
|
||||||
// still has its desired effect
|
// still has its desired effect
|
||||||
|
|
||||||
// GetCurrentThreadId, GetWindowThreadProcessId, FindWindowEx,
|
// GetCurrentThreadId, GetWindowThreadProcessId, FindWindowEx,
|
||||||
// and GetForegroundWindow are used for determining whether to
|
// and GetForegroundWindow are used for determining whether to
|
||||||
// handle input and for positioning
|
// handle input and for positioning
|
||||||
|
|
||||||
// It's a super janky system, but I must abide by it
|
// It's a super janky system, but I must abide by it
|
||||||
|
|
||||||
SDL_SysWMinfo wm;
|
|
||||||
|
|
||||||
char *fname = RSTRING_PTR(rb_iv_get(self, "_funcname"));
|
char *fname = RSTRING_PTR(rb_iv_get(self, "_funcname"));
|
||||||
#define func_is(x) !strcmp(fname, x)
|
#define func_is(x) !strcmp(fname, x)
|
||||||
#define if_func_is(x) if (func_is(x))
|
#define if_func_is(x) if (func_is(x))
|
||||||
if (func_is("GetCurrentThreadId") || func_is("GetWindowThreadProcessId"))
|
if (func_is("GetCurrentThreadId") || func_is("GetWindowThreadProcessId"))
|
||||||
{
|
{
|
||||||
ret = 571; // Dummy
|
ret = 571; // Dummy
|
||||||
}
|
}
|
||||||
else if_func_is("FindWindowEx")
|
else if_func_is("FindWindowEx")
|
||||||
{
|
{
|
||||||
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
|
ret = 571;
|
||||||
ret = (unsigned long)wm.info.win.window;
|
|
||||||
}
|
}
|
||||||
else if_func_is("GetForegroundWindow")
|
else if_func_is("GetForegroundWindow")
|
||||||
{
|
{
|
||||||
if (SDL_GetWindowFlags(shState->sdlWindow()) & SDL_WINDOW_INPUT_FOCUS)
|
if (SDL_GetWindowFlags(shState->sdlWindow()) & SDL_WINDOW_INPUT_FOCUS)
|
||||||
{
|
{
|
||||||
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
|
ret = 571;
|
||||||
ret = (unsigned long)wm.info.win.window;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -243,6 +238,12 @@ MiniFFI_call(int argc, VALUE *argv, VALUE self)
|
||||||
output[1] = y;
|
output[1] = y;
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
else if_func_is("SetWindowPos")
|
||||||
|
{
|
||||||
|
SDL_SetWindowSize(shState->sdlWindow(),params[4],params[5]-24);
|
||||||
|
SDL_SetWindowPosition(shState->sdlWindow(),params[2],params[3]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = (unsigned long)ApiFunction(param);
|
ret = (unsigned long)ApiFunction(param);
|
||||||
|
|
Loading…
Add table
Reference in a new issue