Compare commits
No commits in common. "master" and "show_exc_fixes" have entirely different histories.
master
...
show_exc_f
|
@ -1,5 +0,0 @@
|
|||
root=true
|
||||
[*]
|
||||
end_of_line = lf
|
||||
indent_style = tab
|
||||
indent_size = 4
|
|
@ -3,7 +3,7 @@ Project(mkxp)
|
|||
|
||||
## Setup options ##
|
||||
|
||||
option(SHARED_FLUID "Dynamically link fluidsynth at build time" OFF)
|
||||
option(MIDI "Enable midi support" ON)
|
||||
option(WORKDIR_CURRENT "Keep current directory on startup" OFF)
|
||||
option(FORCE32 "Force 32bit compile on 64bit OS" OFF)
|
||||
set(BINDING "MRI" CACHE STRING "The Binding Type (MRI, MRUBY, NULL)")
|
||||
|
@ -110,7 +110,6 @@ set(MAIN_HEADERS
|
|||
src/flashable.h
|
||||
src/font.h
|
||||
src/input.h
|
||||
src/iniconfig.h
|
||||
src/plane.h
|
||||
src/scene.h
|
||||
src/sprite.h
|
||||
|
@ -125,9 +124,8 @@ set(MAIN_HEADERS
|
|||
src/glstate.h
|
||||
src/quad.h
|
||||
src/tilemap.h
|
||||
src/tilemap-common.h
|
||||
src/graphics.h
|
||||
src/gl-debug.h
|
||||
src/debuglogger.h
|
||||
src/global-ibo.h
|
||||
src/exception.h
|
||||
src/filesystem.h
|
||||
|
@ -137,8 +135,6 @@ set(MAIN_HEADERS
|
|||
src/gl-util.h
|
||||
src/util.h
|
||||
src/config.h
|
||||
src/settingsmenu.h
|
||||
src/keybindings.h
|
||||
src/tileatlas.h
|
||||
src/sharedstate.h
|
||||
src/al-util.h
|
||||
|
@ -155,9 +151,6 @@ set(MAIN_HEADERS
|
|||
src/windowvx.h
|
||||
src/tilemapvx.h
|
||||
src/tileatlasvx.h
|
||||
src/sharedmidistate.h
|
||||
src/fluid-fun.h
|
||||
src/sdl-util.h
|
||||
)
|
||||
|
||||
set(MAIN_SOURCE
|
||||
|
@ -168,7 +161,6 @@ set(MAIN_SOURCE
|
|||
src/filesystem.cpp
|
||||
src/font.cpp
|
||||
src/input.cpp
|
||||
src/iniconfig.cpp
|
||||
src/plane.cpp
|
||||
src/scene.cpp
|
||||
src/sprite.cpp
|
||||
|
@ -182,11 +174,9 @@ set(MAIN_SOURCE
|
|||
src/tilemap.cpp
|
||||
src/autotiles.cpp
|
||||
src/graphics.cpp
|
||||
src/gl-debug.cpp
|
||||
src/debuglogger.cpp
|
||||
src/etc.cpp
|
||||
src/config.cpp
|
||||
src/settingsmenu.cpp
|
||||
src/keybindings.cpp
|
||||
src/tileatlas.cpp
|
||||
src/sharedstate.cpp
|
||||
src/gl-fun.cpp
|
||||
|
@ -203,46 +193,32 @@ set(MAIN_SOURCE
|
|||
src/tilemapvx.cpp
|
||||
src/tileatlasvx.cpp
|
||||
src/autotilesvx.cpp
|
||||
src/midisource.cpp
|
||||
src/fluid-fun.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND MAIN_HEADERS windows/resource.h)
|
||||
list(APPEND MAIN_SOURCE windows/resource.rc)
|
||||
endif()
|
||||
|
||||
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
|
||||
|
||||
## Setup embedded source ##
|
||||
|
||||
set(EMBEDDED_INPUT
|
||||
shader/common.h
|
||||
shader/transSimple.frag
|
||||
shader/trans.frag
|
||||
shader/hue.frag
|
||||
shader/sprite.frag
|
||||
shader/plane.frag
|
||||
shader/gray.frag
|
||||
shader/bitmapBlit.frag
|
||||
shader/flatColor.frag
|
||||
shader/simple.frag
|
||||
shader/simpleColor.frag
|
||||
shader/simpleAlpha.frag
|
||||
shader/simpleAlphaUni.frag
|
||||
shader/flashMap.frag
|
||||
shader/minimal.vert
|
||||
shader/simple.vert
|
||||
shader/simpleColor.vert
|
||||
shader/sprite.vert
|
||||
shader/tilemap.vert
|
||||
shader/tilemapvx.vert
|
||||
shader/blur.frag
|
||||
shader/blurH.vert
|
||||
shader/blurV.vert
|
||||
shader/simpleMatrix.vert
|
||||
assets/liberation.ttf
|
||||
assets/icon.png
|
||||
)
|
||||
|
||||
if (RGSS2)
|
||||
|
@ -251,10 +227,16 @@ if (RGSS2)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (SHARED_FLUID)
|
||||
pkg_check_modules(FLUID REQUIRED fluidsynth)
|
||||
if (MIDI)
|
||||
pkg_check_modules(MIDI REQUIRED fluidsynth)
|
||||
list(APPEND DEFINES
|
||||
SHARED_FLUID
|
||||
MIDI
|
||||
)
|
||||
list(APPEND MAIN_HEADERS
|
||||
src/sharedmidistate.h
|
||||
)
|
||||
list(APPEND MAIN_SOURCE
|
||||
src/midisource.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -294,7 +276,7 @@ source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE})
|
|||
## Setup binding source ##
|
||||
|
||||
if (BINDING STREQUAL "MRI")
|
||||
set(MRIVERSION "2.1" CACHE STRING "Version of MRI to link with")
|
||||
set(MRIVERSION "2.0" CACHE STRING "Version of MRI to link with")
|
||||
pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION})
|
||||
list(APPEND DEFINES
|
||||
BINDING_MRI
|
||||
|
@ -386,7 +368,6 @@ if(APPLE)
|
|||
list(APPEND PLATFORM_LIBRARIES
|
||||
${CARBON_LIBRARY}
|
||||
${IOKIT_LIBRARY}
|
||||
"-liconv"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -412,16 +393,14 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE
|
|||
)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
src
|
||||
windows
|
||||
${SIGCXX_INCLUDE_DIRS}
|
||||
${PIXMAN_INCLUDE_DIRS}
|
||||
${PHYSFS_INCLUDE_DIRS}
|
||||
${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory
|
||||
${SDL_SOUND_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIR}
|
||||
${MRI_INCLUDE_DIRS}
|
||||
${VORBISFILE_INCLUDE_DIRS}
|
||||
${FLUID_INCLUDE_DIRS}
|
||||
${MIDI_INCLUDE_DIRS}
|
||||
${OPENAL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
|
@ -436,7 +415,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
${Boost_LIBRARIES}
|
||||
${MRI_LIBRARIES}
|
||||
${VORBISFILE_LIBRARIES}
|
||||
${FLUID_LIBRARIES}
|
||||
${MIDI_LIBRARIES}
|
||||
${OPENAL_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
|
||||
|
|
54
README.md
54
README.md
|
@ -1,19 +1,26 @@
|
|||
# mkxp
|
||||
|
||||
Discord community: https://discord.gg/A8xHE8P
|
||||
Matrix space: https://matrix.to/#/#rpgmaker:mapleshrine.eu
|
||||
Further links: https://mapleshrine.eu
|
||||
|
||||
mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP", "RPG Maker VX" and "RPG Maker VX Ace" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file.
|
||||
mkxp is a project that seeks to provide a fully open source implementation of the Ruby Game Scripting System (RGSS) interface used in the popular game creation software "RPG Maker XP" (trademark by Enterbrain, Inc.), with focus on Linux. The goal is to be able to run games created with the above software natively without changing a single file. Experimental support for RPG Maker VX / VX Ace games is present.
|
||||
|
||||
It is licensed under the GNU General Public License v2+.
|
||||
|
||||
## Prebuilt binaries
|
||||
[**Linux / Windows**](https://www.mapleshrine.eu/releases/)
|
||||
[**OSX**](https://app.box.com/mkxpmacbuilds) by Ali
|
||||
## RGSS2 / RGSS3
|
||||
Support for these RGSS versions is experimental. A lot is implemented (to the point that you can play the VX Ace sample game, with caveats), but not everything is in place yet. Note that there is no cmake support for building these at the moment.
|
||||
|
||||
## Should I use mkxp
|
||||
mkxp primarily targets technically versed users that are comfortable with Ruby / RGSS, and ideally know how to compile the project themselves. The reason for this is that for most games, due to Win32-API usage, mkxp is simply not a plug-and-play solution, but a building block with which a fully cross-platform version can be created in time.
|
||||
Missing RGSS2 functionality:
|
||||
|
||||
* Text shadow
|
||||
|
||||
Missing RGSS3 functionality:
|
||||
|
||||
* Text outline
|
||||
* Movie playback
|
||||
* F12 reset
|
||||
* Audio fade-in
|
||||
|
||||
Some other things might be implemented, but simply not bound yet.
|
||||
|
||||
RGSS2 might work a little bit less than 3 because I don't have a VX license and as such am unable to experiment thoroughly on it.
|
||||
|
||||
## Bindings
|
||||
Bindings provide the glue code for an interpreted language environment to run game scripts in. Currently there are three bindings:
|
||||
|
@ -26,8 +33,6 @@ Matz's Ruby Interpreter, also called CRuby, is the most widely deployed version
|
|||
For a list of differences, see:
|
||||
http://stackoverflow.com/questions/21574/what-is-the-difference-between-ruby-1-8-and-ruby-1-9
|
||||
|
||||
This binding supports RGSS1, RGSS2 and RGSS3.
|
||||
|
||||
### mruby (Lightweight Ruby)
|
||||
Website: https://github.com/mruby/mruby
|
||||
|
||||
|
@ -37,8 +42,6 @@ Due to heavy differences between mruby and MRI as well as lacking modules, runni
|
|||
|
||||
Some extensions to the standard classes/modules are provided, taking the RPG Maker XP helpfile as a quasi "reference". These include Marshal, File, FileTest and Time.
|
||||
|
||||
This binding only supports RGSS1.
|
||||
|
||||
**Important:** If you decide to use [mattn's oniguruma regexp gem](https://github.com/mattn/mruby-onig-regexp), don't forget to add `-lonig` to the linker flags to avoid ugly symbol overlaps with libc.
|
||||
|
||||
### null
|
||||
|
@ -51,32 +54,31 @@ This binding only exists for testing purposes and does nothing (the engine quits
|
|||
* libsigc++ 2.0
|
||||
* PhysFS (latest hg)
|
||||
* OpenAL
|
||||
* SDL2*
|
||||
* SDL2
|
||||
* SDL2_image
|
||||
* SDL2_ttf
|
||||
* [my SDL_sound fork](https://github.com/Ancurio/SDL_sound)
|
||||
* SDL_sound (latest hg, apply provided patches!)
|
||||
* vorbisfile
|
||||
* pixman
|
||||
* fluidsynth (if midi enabled)
|
||||
* zlib (only ruby bindings)
|
||||
* OpenGL header (alternatively GLES2 with `DEFINES+=GLES2_HEADER`)
|
||||
* libiconv (on Windows, optional with INI_ENCODING)
|
||||
* libguess (optional with INI_ENCODING)
|
||||
|
||||
(* For the F1 menu to work correctly under Linux/X11, you need latest hg + [this patch](https://bugzilla.libsdl.org/show_bug.cgi?id=2745))
|
||||
|
||||
mkxp employs Qt's qmake build system, so you'll need to install that beforehand. Alternatively, you can build with cmake (FIXME: add cmake instructions).
|
||||
|
||||
qmake will use pkg-config to locate the respective include/library paths. If you installed any dependencies into non-standard prefixes, make sure to adjust your `PKG_CONFIG_PATH` variable accordingly.
|
||||
|
||||
The exception is boost, which is weird in that it still hasn't managed to pull off pkg-config support (seriously?). *If you installed boost in a non-standard prefix*, you will need to pass its include path via `BOOST_I` and library path via `BOOST_L`, either as direct arguments to qmake (`qmake BOOST_I="/usr/include" ...`) or via environment variables. You can specify a library suffix (eg. "-mt") via `BOOST_LIB_SUFFIX` if needed.
|
||||
|
||||
Midi support is enabled by default and requires fluidsynth to be present at runtime (not needed for building); if mkxp can't find it at runtime, midi playback is disabled. It looks for `libfluidsynth.so.1` on Linux, `libfluidsynth.dylib.1` on OSX and `fluidsynth.dll` on Windows, so make sure to have one of these in your link path. If you still need fluidsynth to be hard linked at buildtime, use `CONFIG+=SHARED_FLUID`. When building fluidsynth yourself, you can disable almost all options (audio drivers etc.) as they are not used. Note that upstream fluidsynth has support for sharing soundfont data between synthesizers (mkxp uses multiple synths), so if your memory usage is very high, you might want to try compiling fluidsynth from git master.
|
||||
Midi support is enabled by default; you can disable it via `qmake CONFIG+=DISABLE_MIDI`, in which case the fluidsynth dependency is dropped. When building fluidsynth yourself, you can disable almost all options (audio drivers etc.) as they are not used. Note that upstream fluidsynth has support for sharing soundfont data between synthesizers (mkxp uses multiple synths), so if your memory usage is very high, you might want to try compiling fluidsynth from git master.
|
||||
|
||||
By default, mkxp switches into the directory where its binary is contained and then starts reading the configuration and resolving relative paths. In case this is undesired (eg. when the binary is to be installed to a system global, read-only location), it can be turned off by adding `DEFINES+=WORKDIR_CURRENT` to qmake's arguments.
|
||||
|
||||
To auto detect the encoding of the game title in `Game.ini` and auto convert it to UTF-8, build with `CONFIG+=INI_ENCODING`. Requires iconv implementation and libguess. If the encoding is wrongly detected, you can set the "titleLanguage" hint in mkxp.conf.
|
||||
|
||||
**MRI-Binding**: pkg-config will look for `ruby-2.1.pc`, but you can override the version with `MRIVERSION=2.2` ('2.2' being an example). This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit).
|
||||
**MRI-Binding**: pkg-config will look for `ruby-2.1.pc`, but you can modify mkxp.pro to use 2.0 instead. This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit).
|
||||
|
||||
**MRuby-Binding**: place the "mruby" folder into the project folder and build it first. Add `BINDING=MRUBY` to qmake's arguments.
|
||||
|
||||
|
@ -87,10 +89,6 @@ These depend on the SDL auxiliary libraries. For maximum RGSS compliance, build
|
|||
|
||||
To run mkxp, you should have a graphics card capable of at least **OpenGL (ES) 2.0** with an up-to-date driver installed.
|
||||
|
||||
## Dependency kit
|
||||
|
||||
To facilitate hacking, I have assembled a package containing all dependencies to compile mkxp on a bare-bones Ubuntu 12.04 64bit installation. Compatibility with other distributions has not been tested. You can download it [here](https://mapleshrine.eu/depkits/linux64.tar.xz). Read the "README" for instructions.
|
||||
|
||||
## Configuration
|
||||
|
||||
mkxp reads configuration data from the file "mkxp.conf". The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'mkxp.conf.sample' for a list of accepted entries.
|
||||
|
@ -101,11 +99,13 @@ The syntax is: `--<option>=<value>`
|
|||
|
||||
Example: `./mkxp --gameFolder="my game" --vsync=true --fixedFramerate=60`
|
||||
|
||||
## Midi music
|
||||
## Midi music (*ALPHA STATUS*)
|
||||
|
||||
mkxp doesn't come with a soundfont by default, so you will have to supply it yourself (set its path in the config). Playback has been tested and should work reasonably well with all RTP assets.
|
||||
|
||||
You can use this public domain soundfont: [GMGSx.sf2](https://mapleshrine.eu/unsorted/GMGSx.sf2)
|
||||
Known issues with midi playback:
|
||||
|
||||
* Some songs' instruments become mute after looping
|
||||
|
||||
## Fonts
|
||||
|
||||
|
@ -115,9 +115,9 @@ If a requested font is not found, no error is generated. Instead, a built-in fon
|
|||
|
||||
## What doesn't work (yet)
|
||||
|
||||
* Movie playback
|
||||
* wma audio files
|
||||
* The Win32API ruby class (for obvious reasons)
|
||||
* Restarting the game with F12
|
||||
* Creating Bitmaps with sizes greater than the OpenGL texture size limit (around 8192 on modern cards)*
|
||||
|
||||
\* There is an exception to this, called *mega surface*. When a Bitmap bigger than the texture limit is created from a file, it is not stored in VRAM, but regular RAM. Its sole purpose is to be used as a tileset bitmap. Any other operation to it (besides blitting to a regular Bitmap) will result in an error.
|
||||
|
|
BIN
assets/icon.png
BIN
assets/icon.png
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
|
@ -1,50 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
width="100"
|
||||
height="100"
|
||||
id="svg2">
|
||||
<defs
|
||||
id="defs4">
|
||||
<linearGradient
|
||||
id="linearGradient3821">
|
||||
<stop
|
||||
id="stop3823"
|
||||
style="stop-color:#00ff88;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop3825"
|
||||
style="stop-color:#00ff86;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
transform="translate(-323.76562,-436.67187)"
|
||||
id="layer1">
|
||||
<path
|
||||
d="m 373.76195,439.49229 c -26.05643,0 -47.17591,21.12683 -47.17591,47.18326 0,26.05643 21.11948,47.17591 47.17591,47.17591 26.05643,0 47.18326,-21.11948 47.18326,-47.17591 0,-26.05643 -21.12683,-47.18326 -47.18326,-47.18326 z m 0,26.80867 c 11.25095,0 20.37459,9.12364 20.37459,20.37459 0,11.25094 -9.12364,20.36724 -20.37459,20.36724 -11.25094,0 -20.36724,-9.1163 -20.36724,-20.36724 0,-11.25095 9.1163,-20.37459 20.36724,-20.37459 z"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path2985"
|
||||
style="fill:#00ff87;fill-opacity:1;stroke:#000000;stroke-width:5.64083672;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" />
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.8 KiB |
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -97,24 +97,6 @@ DEF_FADE( me )
|
|||
|
||||
DEF_PLAY_STOP( se )
|
||||
|
||||
RB_METHOD(audioSetupMidi)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
shState->audio().setupMidi();
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(audioReset)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
shState->audio().reset();
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
|
||||
#define BIND_PLAY_STOP(entity) \
|
||||
_rb_define_module_function(module, #entity "_play", audio_##entity##Play); \
|
||||
|
@ -144,11 +126,7 @@ audioBindingInit()
|
|||
{
|
||||
BIND_POS( bgm );
|
||||
BIND_POS( bgs );
|
||||
|
||||
_rb_define_module_function(module, "setup_midi", audioSetupMidi);
|
||||
}
|
||||
|
||||
BIND_PLAY_STOP( se )
|
||||
|
||||
_rb_define_module_function(module, "__reset__", audioReset);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -25,10 +25,8 @@
|
|||
#include "eventthread.h"
|
||||
#include "filesystem.h"
|
||||
#include "util.h"
|
||||
#include "sdl-util.h"
|
||||
#include "debugwriter.h"
|
||||
#include "graphics.h"
|
||||
#include "audio.h"
|
||||
#include "boost-hash.h"
|
||||
|
||||
#include <ruby.h>
|
||||
|
@ -46,13 +44,11 @@ extern const char module_rpg3[];
|
|||
|
||||
static void mriBindingExecute();
|
||||
static void mriBindingTerminate();
|
||||
static void mriBindingReset();
|
||||
|
||||
ScriptBinding scriptBindingImpl =
|
||||
{
|
||||
mriBindingExecute,
|
||||
mriBindingTerminate,
|
||||
mriBindingReset
|
||||
mriBindingTerminate
|
||||
};
|
||||
|
||||
ScriptBinding *scriptBinding = &scriptBindingImpl;
|
||||
|
@ -77,10 +73,8 @@ void fileIntBindingInit();
|
|||
|
||||
RB_METHOD(mriPrint);
|
||||
RB_METHOD(mriP);
|
||||
RB_METHOD(mkxpDataDirectory);
|
||||
RB_METHOD(mriDataDirectory);
|
||||
RB_METHOD(mkxpPuts);
|
||||
RB_METHOD(mkxpRawKeyStates);
|
||||
RB_METHOD(mkxpMouseInWindow);
|
||||
|
||||
RB_METHOD(mriRgssMain);
|
||||
RB_METHOD(mriRgssStop);
|
||||
|
@ -121,7 +115,7 @@ static void mriBindingInit()
|
|||
_rb_define_module_function(rb_mKernel, "msgbox", mriPrint);
|
||||
_rb_define_module_function(rb_mKernel, "msgbox_p", mriP);
|
||||
|
||||
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.1"));
|
||||
rb_define_global_const("RGSS_VERSION", rb_str_new_cstr("3.0.0"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -141,22 +135,11 @@ static void mriBindingInit()
|
|||
else
|
||||
assert(!"unreachable");
|
||||
|
||||
VALUE mod = rb_define_module("MKXP");
|
||||
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
|
||||
VALUE mod = rb_define_module("System");
|
||||
_rb_define_module_function(mod, "data_directory", mriDataDirectory);
|
||||
_rb_define_module_function(mod, "puts", mkxpPuts);
|
||||
_rb_define_module_function(mod, "raw_key_states", mkxpRawKeyStates);
|
||||
_rb_define_module_function(mod, "mouse_in_window", mkxpMouseInWindow);
|
||||
|
||||
/* Load global constants */
|
||||
rb_gv_set("MKXP", Qtrue);
|
||||
|
||||
VALUE debug = rb_bool_new(shState->config().editor.debug);
|
||||
if (rgssVer == 1)
|
||||
rb_gv_set("DEBUG", debug);
|
||||
else if (rgssVer >= 2)
|
||||
rb_gv_set("TEST", debug);
|
||||
|
||||
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -165,6 +148,18 @@ showMsg(const std::string &msg)
|
|||
shState->eThread().showMessageBox(msg.c_str());
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpPuts)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const char *str;
|
||||
rb_get_args(argc, argv, "z", &str RB_ARG_END);
|
||||
|
||||
Debug() << str;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static void printP(int argc, VALUE *argv,
|
||||
const char *convMethod, const char *sep)
|
||||
{
|
||||
|
@ -201,90 +196,29 @@ RB_METHOD(mriP)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpDataDirectory)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const std::string &path = shState->config().customDataPath;
|
||||
const char *s = path.empty() ? "." : path.c_str();
|
||||
|
||||
return rb_str_new_cstr(s);
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpPuts)
|
||||
RB_METHOD(mriDataDirectory)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const char *str;
|
||||
rb_get_args(argc, argv, "z", &str RB_ARG_END);
|
||||
const char *org, *app;
|
||||
|
||||
Debug() << str;
|
||||
rb_get_args(argc, argv, "zz", &org, &app RB_ARG_END);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
char *path = SDL_GetPrefPath(org, app);
|
||||
|
||||
RB_METHOD(mkxpRawKeyStates)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
VALUE pathStr = rb_str_new_cstr(path);
|
||||
|
||||
VALUE str = rb_str_new(0, sizeof(EventThread::keyStates));
|
||||
memcpy(RSTRING_PTR(str), EventThread::keyStates, sizeof(EventThread::keyStates));
|
||||
SDL_free(path);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpMouseInWindow)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
return rb_bool_new(EventThread::mouseState.inWindow);
|
||||
}
|
||||
|
||||
static VALUE rgssMainCb(VALUE block)
|
||||
{
|
||||
rb_funcall2(block, rb_intern("call"), 0, 0);
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE rgssMainRescue(VALUE arg, VALUE exc)
|
||||
{
|
||||
VALUE *excRet = (VALUE*) arg;
|
||||
|
||||
*excRet = exc;
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static void processReset()
|
||||
{
|
||||
shState->graphics().reset();
|
||||
shState->audio().reset();
|
||||
|
||||
shState->rtData().rqReset.clear();
|
||||
shState->graphics().repaintWait(shState->rtData().rqResetFinish,
|
||||
false);
|
||||
return pathStr;
|
||||
}
|
||||
|
||||
RB_METHOD(mriRgssMain)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
while (true)
|
||||
{
|
||||
VALUE exc = Qnil;
|
||||
|
||||
rb_rescue2((VALUE(*)(ANYARGS)) rgssMainCb, rb_block_proc(),
|
||||
(VALUE(*)(ANYARGS)) rgssMainRescue, (VALUE) &exc,
|
||||
rb_eException, (VALUE) 0);
|
||||
|
||||
if (NIL_P(exc))
|
||||
break;
|
||||
|
||||
if (rb_obj_class(exc) == getRbData()->exc[Reset])
|
||||
processReset();
|
||||
else
|
||||
rb_exc_raise(exc);
|
||||
}
|
||||
// TODO: Implement F12 reset
|
||||
rb_yield(Qnil);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -358,7 +292,7 @@ static void runCustomScript(const std::string &filename)
|
|||
{
|
||||
std::string scriptData;
|
||||
|
||||
if (!readFileSDL(filename.c_str(), scriptData))
|
||||
if (!readFile(filename.c_str(), scriptData))
|
||||
{
|
||||
showMsg(std::string("Unable to open '") + filename + "'");
|
||||
return;
|
||||
|
@ -368,7 +302,7 @@ static void runCustomScript(const std::string &filename)
|
|||
newStringUTF8(filename.c_str(), filename.size()), NULL);
|
||||
}
|
||||
|
||||
VALUE kernelLoadDataInt(const char *filename, bool rubyExc);
|
||||
VALUE kernelLoadDataInt(const char *filename);
|
||||
|
||||
struct BacktraceData
|
||||
{
|
||||
|
@ -395,19 +329,7 @@ static void runRMXPScripts(BacktraceData &btData)
|
|||
return;
|
||||
}
|
||||
|
||||
VALUE scriptArray;
|
||||
|
||||
/* We checked if Scripts.rxdata exists, but something might
|
||||
* still go wrong */
|
||||
try
|
||||
{
|
||||
scriptArray = kernelLoadDataInt(scriptPack.c_str(), false);
|
||||
}
|
||||
catch (const Exception &e)
|
||||
{
|
||||
showMsg(std::string("Failed to read script data: ") + e.msg);
|
||||
return;
|
||||
}
|
||||
VALUE scriptArray = kernelLoadDataInt(scriptPack.c_str());
|
||||
|
||||
if (!RB_TYPE_P(scriptArray, RUBY_T_ARRAY))
|
||||
{
|
||||
|
@ -470,47 +392,33 @@ static void runRMXPScripts(BacktraceData &btData)
|
|||
}
|
||||
|
||||
/* Execute preloaded scripts */
|
||||
for (std::set<std::string>::iterator i = conf.preloadScripts.begin();
|
||||
i != conf.preloadScripts.end(); ++i)
|
||||
runCustomScript(*i);
|
||||
for (size_t i = 0; i < conf.preloadScripts.size(); ++i)
|
||||
runCustomScript(conf.preloadScripts[i]);
|
||||
|
||||
VALUE exc = rb_gv_get("$!");
|
||||
if (exc != Qnil)
|
||||
return;
|
||||
|
||||
while (true)
|
||||
for (long i = 0; i < scriptCount; ++i)
|
||||
{
|
||||
for (long i = 0; i < scriptCount; ++i)
|
||||
{
|
||||
VALUE script = rb_ary_entry(scriptArray, i);
|
||||
VALUE scriptDecoded = rb_ary_entry(script, 3);
|
||||
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
|
||||
RSTRING_LEN(scriptDecoded));
|
||||
VALUE script = rb_ary_entry(scriptArray, i);
|
||||
VALUE scriptDecoded = rb_ary_entry(script, 3);
|
||||
VALUE string = newStringUTF8(RSTRING_PTR(scriptDecoded),
|
||||
RSTRING_LEN(scriptDecoded));
|
||||
|
||||
VALUE fname;
|
||||
const char *scriptName = RSTRING_PTR(rb_ary_entry(script, 1));
|
||||
char buf[512];
|
||||
int len;
|
||||
VALUE fname;
|
||||
const char *scriptName = RSTRING_PTR(rb_ary_entry(script, 1));
|
||||
char buf[512];
|
||||
int len;
|
||||
|
||||
if (conf.useScriptNames)
|
||||
len = snprintf(buf, sizeof(buf), "%03ld:%s", i, scriptName);
|
||||
else
|
||||
len = snprintf(buf, sizeof(buf), SCRIPT_SECTION_FMT, i);
|
||||
if (conf.useScriptNames)
|
||||
len = snprintf(buf, sizeof(buf), "%03ld:%s", i, scriptName);
|
||||
else
|
||||
len = snprintf(buf, sizeof(buf), SCRIPT_SECTION_FMT, i);
|
||||
|
||||
fname = newStringUTF8(buf, len);
|
||||
btData.scriptNames.insert(buf, scriptName);
|
||||
fname = newStringUTF8(buf, len);
|
||||
btData.scriptNames.insert(buf, scriptName);
|
||||
|
||||
int state;
|
||||
evalString(string, fname, &state);
|
||||
if (state)
|
||||
break;
|
||||
}
|
||||
|
||||
VALUE exc = rb_gv_get("$!");
|
||||
if (rb_obj_class(exc) != getRbData()->exc[Reset])
|
||||
int state;
|
||||
evalString(string, fname, &state);
|
||||
if (state)
|
||||
break;
|
||||
|
||||
processReset();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,13 +483,6 @@ static void showExc(VALUE exc, const BacktraceData &btData)
|
|||
|
||||
static void mriBindingExecute()
|
||||
{
|
||||
/* Normally only a ruby executable would do a sysinit,
|
||||
* but not doing it will lead to crashes due to closed
|
||||
* stdio streams on some platforms (eg. Windows) */
|
||||
int argc = 0;
|
||||
char **argv = 0;
|
||||
ruby_sysinit(&argc, &argv);
|
||||
|
||||
ruby_setup();
|
||||
rb_enc_set_default_external(rb_enc_from_encoding(rb_utf8_encoding()));
|
||||
|
||||
|
@ -619,15 +520,10 @@ static void mriBindingExecute()
|
|||
|
||||
ruby_cleanup(0);
|
||||
|
||||
shState->rtData().rqTermAck.set();
|
||||
shState->rtData().rqTermAck = true;
|
||||
}
|
||||
|
||||
static void mriBindingTerminate()
|
||||
{
|
||||
rb_raise(rb_eSystemExit, " ");
|
||||
}
|
||||
|
||||
static void mriBindingReset()
|
||||
{
|
||||
rb_raise(getRbData()->exc[Reset], " ");
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -41,6 +41,7 @@ struct
|
|||
} static customExc[] =
|
||||
{
|
||||
{ MKXP, "MKXPError" },
|
||||
{ RGSS, "RGSSError" },
|
||||
{ PHYSFS, "PHYSFSError" },
|
||||
{ SDL, "SDLError" }
|
||||
};
|
||||
|
@ -50,9 +51,6 @@ RbData::RbData()
|
|||
for (size_t i = 0; i < ARRAY_SIZE(customExc); ++i)
|
||||
exc[customExc[i].id] = rb_define_class(customExc[i].name, rb_eException);
|
||||
|
||||
exc[RGSS] = rb_define_class("RGSSError", rb_eStandardError);
|
||||
exc[Reset] = rb_define_class(rgssVer >= 3 ? "RGSSReset" : "Reset", rb_eException);
|
||||
|
||||
exc[ErrnoENOENT] = rb_const_get(rb_const_get(rb_cObject, rb_intern("Errno")), rb_intern("ENOENT"));
|
||||
exc[IOError] = rb_eIOError;
|
||||
exc[TypeError] = rb_eTypeError;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -29,7 +29,6 @@
|
|||
enum RbException
|
||||
{
|
||||
RGSS = 0,
|
||||
Reset,
|
||||
PHYSFS,
|
||||
SDL,
|
||||
MKXP,
|
||||
|
@ -67,7 +66,7 @@ raiseRbExc(const Exception &exc);
|
|||
|
||||
/* 2.1 has added a new field (flags) to rb_data_type_t */
|
||||
#include <ruby/version.h>
|
||||
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 1
|
||||
#if RUBY_API_VERSION_MINOR > 0
|
||||
/* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
|
||||
#define DEF_TYPE_FLAGS 0
|
||||
#else
|
||||
|
@ -90,12 +89,7 @@ raiseRbExc(const Exception &exc);
|
|||
template<rb_data_type_t *rbType>
|
||||
static VALUE classAllocate(VALUE klass)
|
||||
{
|
||||
/* 2.3 has changed the name of this function */
|
||||
#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3
|
||||
return rb_data_typed_object_wrap(klass, 0, rbType);
|
||||
#else
|
||||
return rb_data_typed_object_alloc(klass, 0, rbType);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class C>
|
||||
|
@ -107,12 +101,22 @@ static void freeInstance(void *inst)
|
|||
void
|
||||
raiseDisposedAccess(VALUE self);
|
||||
|
||||
inline void
|
||||
checkDisposed(VALUE self)
|
||||
{
|
||||
if (!RTYPEDDATA_DATA(self))
|
||||
raiseDisposedAccess(self);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
inline C *
|
||||
getPrivateData(VALUE self)
|
||||
{
|
||||
C *c = static_cast<C*>(RTYPEDDATA_DATA(self));
|
||||
|
||||
if (!c)
|
||||
raiseDisposedAccess(self);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -120,6 +124,8 @@ template<class C>
|
|||
static inline C *
|
||||
getPrivateDataCheck(VALUE self, const rb_data_type_t &type)
|
||||
{
|
||||
/* We don't check for disposed here because any disposable
|
||||
* property is always also nullable */
|
||||
void *obj = Check_TypedStruct(self, &type);
|
||||
return static_cast<C*>(obj);
|
||||
}
|
||||
|
@ -154,6 +160,12 @@ wrapProperty(VALUE self, void *prop, const char *iv,
|
|||
return propObj;
|
||||
}
|
||||
|
||||
inline void
|
||||
wrapNilProperty(VALUE self, const char *iv)
|
||||
{
|
||||
rb_iv_set(self, iv, Qnil);
|
||||
}
|
||||
|
||||
/* Implemented: oSszfibn| */
|
||||
int
|
||||
rb_get_args(int argc, VALUE *argv, const char *format, ...);
|
||||
|
@ -304,11 +316,30 @@ rb_check_argc(int actual, int expected)
|
|||
return self; \
|
||||
}
|
||||
|
||||
/* Object property which is copied by reference, with allowed NIL
|
||||
#define DEF_PROP_OBJ(Klass, PropKlass, PropName, prop_iv) \
|
||||
RB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
checkDisposed(self); \
|
||||
return rb_iv_get(self, prop_iv); \
|
||||
} \
|
||||
RB_METHOD(Klass##Set##PropName) \
|
||||
{ \
|
||||
rb_check_argc(argc, 1); \
|
||||
Klass *k = getPrivateData<Klass>(self); \
|
||||
VALUE propObj = *argv; \
|
||||
PropKlass *prop; \
|
||||
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
|
||||
GUARD_EXC( k->set##PropName(prop); ) \
|
||||
rb_iv_set(self, prop_iv, propObj); \
|
||||
return propObj; \
|
||||
}
|
||||
|
||||
/* Object property with allowed NIL
|
||||
* FIXME: Getter assumes prop is disposable,
|
||||
* because self.disposed? is not checked in this case.
|
||||
* Should make this more clear */
|
||||
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
|
||||
#define DEF_PROP_OBJ_NIL(Klass, PropKlass, PropName, prop_iv) \
|
||||
RB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
|
@ -330,33 +361,12 @@ rb_check_argc(int actual, int expected)
|
|||
return propObj; \
|
||||
}
|
||||
|
||||
/* Object property which is copied by value, not reference */
|
||||
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
|
||||
RB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
checkDisposed<Klass>(self); \
|
||||
return rb_iv_get(self, prop_iv); \
|
||||
} \
|
||||
RB_METHOD(Klass##Set##PropName) \
|
||||
{ \
|
||||
rb_check_argc(argc, 1); \
|
||||
Klass *k = getPrivateData<Klass>(self); \
|
||||
VALUE propObj = *argv; \
|
||||
PropKlass *prop; \
|
||||
prop = getPrivateDataCheck<PropKlass>(propObj, PropKlass##Type); \
|
||||
GUARD_EXC( k->set##PropName(*prop); ) \
|
||||
return propObj; \
|
||||
}
|
||||
|
||||
#define DEF_PROP(Klass, type, PropName, arg_fun, value_fun) \
|
||||
RB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
RB_UNUSED_PARAM; \
|
||||
Klass *k = getPrivateData<Klass>(self); \
|
||||
type value = 0; \
|
||||
GUARD_EXC( value = k->get##PropName(); ) \
|
||||
return value_fun(value); \
|
||||
return value_fun(k->get##PropName()); \
|
||||
} \
|
||||
RB_METHOD(Klass##Set##PropName) \
|
||||
{ \
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -43,7 +43,7 @@ void bitmapInitProps(Bitmap *b, VALUE self)
|
|||
rb_obj_call_init(fontObj, 0, 0);
|
||||
|
||||
Font *font = getPrivateData<Font>(fontObj);
|
||||
b->setInitFont(font);
|
||||
b->setFont(font);
|
||||
|
||||
rb_iv_set(self, "font", fontObj);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ RB_METHOD(bitmapBlt)
|
|||
src = getPrivateDataCheck<Bitmap>(srcObj, BitmapType);
|
||||
srcRect = getPrivateDataCheck<Rect>(srcRectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->blt(x, y, *src, srcRect->toIntRect(), opacity); );
|
||||
GUARD_EXC( b->blt(x, y, src, srcRect->toIntRect(), opacity); );
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ RB_METHOD(bitmapStretchBlt)
|
|||
destRect = getPrivateDataCheck<Rect>(destRectObj, RectType);
|
||||
srcRect = getPrivateDataCheck<Rect>(srcRectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->stretchBlt(destRect->toIntRect(), *src, srcRect->toIntRect(), opacity); );
|
||||
GUARD_EXC( b->stretchBlt(destRect->toIntRect(), src, srcRect->toIntRect(), opacity); );
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ RB_METHOD(bitmapTextSize)
|
|||
return wrapObject(rect, RectType);
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_VAL(Bitmap, Font, Font, "font")
|
||||
DEF_PROP_OBJ(Bitmap, Font, Font, "font")
|
||||
|
||||
RB_METHOD(bitmapGradientFillRect)
|
||||
{
|
||||
|
@ -413,25 +413,12 @@ RB_METHOD(bitmapRadialBlur)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(bitmapInitializeCopy)
|
||||
{
|
||||
rb_check_argc(argc, 1);
|
||||
VALUE origObj = argv[0];
|
||||
|
||||
if (!OBJ_INIT_COPY(self, origObj))
|
||||
return self;
|
||||
|
||||
Bitmap *orig = getPrivateData<Bitmap>(origObj);
|
||||
Bitmap *b = 0;
|
||||
GUARD_EXC( b = new Bitmap(*orig); );
|
||||
|
||||
bitmapInitProps(b, self);
|
||||
b->setFont(orig->getFont());
|
||||
|
||||
setPrivateData(self, b);
|
||||
|
||||
return self;
|
||||
}
|
||||
// FIXME: This isn't entire correct as the cloned bitmap
|
||||
// does not get a cloned version of the original bitmap's 'font'
|
||||
// attribute (the internal font attrb is the default one, whereas
|
||||
// the stored iv visible to ruby would still be the same as the original)
|
||||
// Not sure if this needs fixing though
|
||||
INITCOPY_FUN(Bitmap)
|
||||
|
||||
|
||||
void
|
||||
|
@ -443,7 +430,7 @@ bitmapBindingInit()
|
|||
disposableBindingInit<Bitmap>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", bitmapInitialize);
|
||||
_rb_define_method(klass, "initialize_copy", bitmapInitializeCopy);
|
||||
_rb_define_method(klass, "initialize_copy", BitmapInitializeCopy);
|
||||
|
||||
_rb_define_method(klass, "width", bitmapWidth);
|
||||
_rb_define_method(klass, "height", bitmapHeight);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,7 +27,8 @@
|
|||
|
||||
/* 'Children' are disposables that are disposed together
|
||||
* with their parent. Currently this is only used by Viewport
|
||||
* in RGSS1. */
|
||||
* in RGSS1.
|
||||
* FIXME: Disable this behavior when RGSS2 or 3 */
|
||||
inline void
|
||||
disposableAddChild(VALUE disp, VALUE child)
|
||||
{
|
||||
|
@ -51,8 +52,9 @@ disposableDisposeChildren(VALUE disp)
|
|||
if (NIL_P(children))
|
||||
return;
|
||||
|
||||
ID dispFun = rb_intern("_mkxp_dispose_alias");
|
||||
ID dispFun = rb_intern("dispose");
|
||||
|
||||
/* Note: RMXP doesn't call overridden 'dispose' methods here */
|
||||
for (long i = 0; i < RARRAY_LEN(children); ++i)
|
||||
rb_funcall2(rb_ary_entry(children, i), dispFun, 0, 0);
|
||||
}
|
||||
|
@ -62,54 +64,32 @@ RB_METHOD(disposableDispose)
|
|||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
C *d = getPrivateData<C>(self);
|
||||
|
||||
if (!d)
|
||||
return Qnil;
|
||||
C *c = static_cast<C*>(RTYPEDDATA_DATA(self));
|
||||
|
||||
/* Nothing to do if already disposed */
|
||||
if (d->isDisposed())
|
||||
if (!c)
|
||||
return Qnil;
|
||||
|
||||
if (rgssVer == 1)
|
||||
disposableDisposeChildren(self);
|
||||
disposableDisposeChildren(self);
|
||||
|
||||
d->dispose();
|
||||
delete c;
|
||||
setPrivateData(self, 0);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
RB_METHOD(disposableIsDisposed)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
C *d = getPrivateData<C>(self);
|
||||
|
||||
if (!d)
|
||||
return Qtrue;
|
||||
|
||||
return rb_bool_new(d->isDisposed());
|
||||
return rb_bool_new(RTYPEDDATA_DATA(self) == 0);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
static void disposableBindingInit(VALUE klass)
|
||||
{
|
||||
_rb_define_method(klass, "dispose", disposableDispose<C>);
|
||||
_rb_define_method(klass, "disposed?", disposableIsDisposed<C>);
|
||||
|
||||
/* Make sure we always have access to the original method, even
|
||||
* if it is overridden by user scripts */
|
||||
if (rgssVer == 1)
|
||||
rb_define_alias(klass, "_mkxp_dispose_alias", "dispose");
|
||||
}
|
||||
|
||||
template<class C>
|
||||
inline void
|
||||
checkDisposed(VALUE self)
|
||||
{
|
||||
if (disposableIsDisposed<C>(0, 0, self) == Qtrue)
|
||||
raiseDisposedAccess(self);
|
||||
_rb_define_method(klass, "disposed?", disposableIsDisposed);
|
||||
}
|
||||
|
||||
#endif // DISPOSABLEBINDING_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,7 +22,6 @@
|
|||
#include "etc.h"
|
||||
#include "binding-util.h"
|
||||
#include "serializable-binding.h"
|
||||
#include "sharedstate.h"
|
||||
|
||||
DEF_TYPE(Color);
|
||||
DEF_TYPE(Tone);
|
||||
|
@ -69,9 +68,6 @@ ATTR_INT_RW(Rect, Height)
|
|||
VALUE otherObj; \
|
||||
Klass *other; \
|
||||
rb_get_args(argc, argv, "o", &otherObj RB_ARG_END); \
|
||||
if (rgssVer >= 3) \
|
||||
if (!rb_typeddata_is_kind_of(otherObj, &Klass##Type)) \
|
||||
return Qfalse; \
|
||||
other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
|
||||
return rb_bool_new(*p == *other); \
|
||||
}
|
||||
|
@ -110,7 +106,7 @@ INIT_FUN(Rect, int, "iiii", 0)
|
|||
{ \
|
||||
VALUE otherObj = argv[0]; \
|
||||
Klass *other = getPrivateDataCheck<Klass>(otherObj, Klass##Type); \
|
||||
*k = *other; \
|
||||
k->set(*other); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
|
@ -181,8 +177,6 @@ INITCOPY_FUN(Rect)
|
|||
_rb_define_method(klass, "initialize_copy", Klass##InitializeCopy); \
|
||||
_rb_define_method(klass, "set", Klass##Set); \
|
||||
_rb_define_method(klass, "==", Klass##Equal); \
|
||||
_rb_define_method(klass, "===", Klass##Equal); \
|
||||
_rb_define_method(klass, "eql?", Klass##Equal); \
|
||||
_rb_define_method(klass, "to_s", Klass##Stringify); \
|
||||
_rb_define_method(klass, "inspect", Klass##Stringify); \
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -40,23 +40,10 @@ fileIntFreeInstance(void *inst)
|
|||
DEF_TYPE_CUSTOMFREE(FileInt, fileIntFreeInstance);
|
||||
|
||||
static VALUE
|
||||
fileIntForPath(const char *path, bool rubyExc)
|
||||
fileIntForPath(const char *path)
|
||||
{
|
||||
SDL_RWops *ops = SDL_AllocRW();
|
||||
|
||||
try
|
||||
{
|
||||
shState->fileSystem().openReadRaw(*ops, path);
|
||||
}
|
||||
catch (const Exception &e)
|
||||
{
|
||||
SDL_FreeRW(ops);
|
||||
|
||||
if (rubyExc)
|
||||
raiseRbExc(e);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
shState->fileSystem().openRead(*ops, path);
|
||||
|
||||
VALUE klass = rb_const_get(rb_cObject, rb_intern("FileInt"));
|
||||
|
||||
|
@ -123,11 +110,11 @@ RB_METHOD(fileIntBinmode)
|
|||
}
|
||||
|
||||
VALUE
|
||||
kernelLoadDataInt(const char *filename, bool rubyExc)
|
||||
kernelLoadDataInt(const char *filename)
|
||||
{
|
||||
rb_gc_start();
|
||||
|
||||
VALUE port = fileIntForPath(filename, rubyExc);
|
||||
VALUE port = fileIntForPath(filename);
|
||||
|
||||
VALUE marsh = rb_const_get(rb_cObject, rb_intern("Marshal"));
|
||||
|
||||
|
@ -146,7 +133,7 @@ RB_METHOD(kernelLoadData)
|
|||
const char *filename;
|
||||
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
|
||||
|
||||
return kernelLoadDataInt(filename, true);
|
||||
return kernelLoadDataInt(filename);
|
||||
}
|
||||
|
||||
RB_METHOD(kernelSaveData)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,29 +27,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static void
|
||||
collectStrings(VALUE obj, std::vector<std::string> &out)
|
||||
{
|
||||
if (RB_TYPE_P(obj, RUBY_T_STRING))
|
||||
{
|
||||
out.push_back(RSTRING_PTR(obj));
|
||||
}
|
||||
else if (RB_TYPE_P(obj, RUBY_T_ARRAY))
|
||||
{
|
||||
for (long i = 0; i < RARRAY_LEN(obj); ++i)
|
||||
{
|
||||
VALUE str = rb_ary_entry(obj, i);
|
||||
|
||||
/* Non-string objects are tolerated (ignored) */
|
||||
if (!RB_TYPE_P(str, RUBY_T_STRING))
|
||||
continue;
|
||||
|
||||
out.push_back(RSTRING_PTR(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEF_TYPE(Font);
|
||||
|
||||
RB_METHOD(fontDoesExist)
|
||||
|
@ -71,40 +48,31 @@ RB_METHOD(FontSetName);
|
|||
|
||||
RB_METHOD(fontInitialize)
|
||||
{
|
||||
VALUE namesObj = Qnil;
|
||||
VALUE name = Qnil;
|
||||
int size = 0;
|
||||
|
||||
rb_get_args(argc, argv, "|oi", &namesObj, &size RB_ARG_END);
|
||||
rb_get_args(argc, argv, "|oi", &name, &size RB_ARG_END);
|
||||
|
||||
Font *f;
|
||||
|
||||
if (NIL_P(namesObj))
|
||||
{
|
||||
namesObj = rb_iv_get(rb_obj_class(self), "default_name");
|
||||
f = new Font(0, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
collectStrings(namesObj, names);
|
||||
|
||||
f = new Font(&names, size);
|
||||
}
|
||||
|
||||
/* This is semantically wrong; the new Font object should take
|
||||
* a dup'ed object here in case of an array. Ditto for the setters.
|
||||
* However the same bug/behavior exists in all RM versions. */
|
||||
rb_iv_set(self, "name", namesObj);
|
||||
Font *f = new Font(0, size);
|
||||
|
||||
setPrivateData(self, f);
|
||||
|
||||
/* Wrap property objects */
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(self, &f->getColor(), "color", ColorType);
|
||||
f->setColor(new Color(*f->getColor()));
|
||||
wrapProperty(self, f->getColor(), "color", ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
|
||||
{
|
||||
f->setOutColor(new Color(*f->getOutColor()));
|
||||
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
|
||||
}
|
||||
|
||||
if (NIL_P(name))
|
||||
name = rb_iv_get(rb_obj_class(self), "default_name");
|
||||
|
||||
/* Going over the 'name=' function automatically causes
|
||||
* a possbile name array to be re-verified for existing fonts */
|
||||
FontSetName(1, &name, self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -122,12 +90,14 @@ RB_METHOD(fontInitializeCopy)
|
|||
setPrivateData(self, f);
|
||||
|
||||
/* Wrap property objects */
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(self, &f->getColor(), "color", ColorType);
|
||||
f->setColor(new Color(*f->getColor()));
|
||||
wrapProperty(self, f->getColor(), "color", ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
|
||||
{
|
||||
f->setOutColor(new Color(*f->getOutColor()));
|
||||
wrapProperty(self, f->getOutColor(), "out_color", ColorType);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -139,33 +109,68 @@ RB_METHOD(FontGetName)
|
|||
return rb_iv_get(self, "name");
|
||||
}
|
||||
|
||||
static void
|
||||
fontSetNameHelper(VALUE self, int argc, VALUE *argv,
|
||||
const char *nameIv, char *outBuf, size_t outLen)
|
||||
{
|
||||
rb_check_argc(argc, 1);
|
||||
|
||||
VALUE arg = argv[0];
|
||||
|
||||
// Fixme: in RGSS3, specifying "" (and only that) as font name results in
|
||||
// no text being drawn (everything else is substituted with Arial I think)
|
||||
strncpy(outBuf, "", outLen);
|
||||
|
||||
if (RB_TYPE_P(arg, RUBY_T_STRING))
|
||||
{
|
||||
strncpy(outBuf, RSTRING_PTR(arg), outLen);
|
||||
}
|
||||
else if (RB_TYPE_P(arg, RUBY_T_ARRAY))
|
||||
{
|
||||
for (long i = 0; i < RARRAY_LEN(arg); ++i)
|
||||
{
|
||||
VALUE str = rb_ary_entry(arg, i);
|
||||
|
||||
/* Non-string objects are tolerated (ignored) */
|
||||
if (!RB_TYPE_P(str, RUBY_T_STRING))
|
||||
continue;
|
||||
|
||||
const char *family = RSTRING_PTR(str);
|
||||
|
||||
/* We only set the core Font object's name attribute
|
||||
* to the actually existing font name */
|
||||
if (!shState->fontState().fontPresent(family))
|
||||
continue;
|
||||
|
||||
strncpy(outBuf, family, outLen);
|
||||
}
|
||||
}
|
||||
|
||||
/* RMXP doesn't even care if the argument type is
|
||||
* something other than string/array. Whatever... */
|
||||
rb_iv_set(self, nameIv, arg);
|
||||
}
|
||||
|
||||
RB_METHOD(FontSetName)
|
||||
{
|
||||
Font *f = getPrivateData<Font>(self);
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
char result[256];
|
||||
fontSetNameHelper(self, argc, argv, "default_name",
|
||||
result, sizeof(result));
|
||||
|
||||
std::vector<std::string> namesObj;
|
||||
collectStrings(argv[0], namesObj);
|
||||
|
||||
f->setName(namesObj);
|
||||
rb_iv_set(self, "name", argv[0]);
|
||||
f->setName(result);
|
||||
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
template<class C>
|
||||
static void checkDisposed(VALUE) {}
|
||||
|
||||
DEF_PROP_OBJ_VAL(Font, Color, Color, "color")
|
||||
DEF_PROP_OBJ_VAL(Font, Color, OutColor, "out_color")
|
||||
|
||||
DEF_PROP_I(Font, Size)
|
||||
|
||||
DEF_PROP_B(Font, Bold)
|
||||
DEF_PROP_B(Font, Italic)
|
||||
DEF_PROP_B(Font, Shadow)
|
||||
DEF_PROP_B(Font, Outline)
|
||||
DEF_PROP_OBJ(Font, Color, Color, "color")
|
||||
DEF_PROP_OBJ(Font, Color, OutColor, "out_color")
|
||||
|
||||
#define DEF_KLASS_PROP(Klass, type, PropName, param_t_s, value_fun) \
|
||||
RB_METHOD(Klass##Get##PropName) \
|
||||
|
@ -182,10 +187,10 @@ DEF_PROP_B(Font, Outline)
|
|||
return value_fun(value); \
|
||||
}
|
||||
|
||||
DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, int, DefaultSize, "i", rb_fix_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultBold, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultItalic, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultShadow, "b", rb_bool_new)
|
||||
DEF_KLASS_PROP(Font, bool, DefaultOutline, "b", rb_bool_new)
|
||||
|
||||
RB_METHOD(FontGetDefaultOutColor)
|
||||
|
@ -196,14 +201,13 @@ RB_METHOD(FontGetDefaultOutColor)
|
|||
|
||||
RB_METHOD(FontSetDefaultOutColor)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE colorObj;
|
||||
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
|
||||
|
||||
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||
|
||||
Font::setDefaultOutColor(*c);
|
||||
Font::setDefaultOutColor(c);
|
||||
rb_iv_set(self, "default_out_color", colorObj);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
@ -217,15 +221,11 @@ RB_METHOD(FontGetDefaultName)
|
|||
|
||||
RB_METHOD(FontSetDefaultName)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
char result[256];
|
||||
fontSetNameHelper(self, argc, argv, "default_name",
|
||||
result, sizeof(result));
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
|
||||
std::vector<std::string> namesObj;
|
||||
collectStrings(argv[0], namesObj);
|
||||
|
||||
Font::setDefaultName(namesObj, shState->fontState());
|
||||
rb_iv_set(self, "default_name", argv[0]);
|
||||
Font::setDefaultName(result);
|
||||
|
||||
return argv[0];
|
||||
}
|
||||
|
@ -239,14 +239,13 @@ RB_METHOD(FontGetDefaultColor)
|
|||
|
||||
RB_METHOD(FontSetDefaultColor)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE colorObj;
|
||||
rb_get_args(argc, argv, "o", &colorObj RB_ARG_END);
|
||||
|
||||
Color *c = getPrivateDataCheck<Color>(colorObj, ColorType);
|
||||
|
||||
Font::setDefaultColor(*c);
|
||||
Font::setDefaultColor(c);
|
||||
rb_iv_set(self, "default_color", colorObj);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
@ -263,29 +262,9 @@ fontBindingInit()
|
|||
VALUE klass = rb_define_class("Font", rb_cObject);
|
||||
rb_define_alloc_func(klass, classAllocate<&FontType>);
|
||||
|
||||
Font::initDefaultDynAttribs();
|
||||
wrapProperty(klass, &Font::getDefaultColor(), "default_color", ColorType);
|
||||
|
||||
/* Initialize default names */
|
||||
const std::vector<std::string> &defNames = Font::getInitialDefaultNames();
|
||||
VALUE defNamesObj;
|
||||
|
||||
if (defNames.size() == 1)
|
||||
{
|
||||
defNamesObj = rb_str_new_cstr(defNames[0].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
defNamesObj = rb_ary_new2(defNames.size());
|
||||
|
||||
for (size_t i = 0; i < defNames.size(); ++i)
|
||||
rb_ary_push(defNamesObj, rb_str_new_cstr(defNames[i].c_str()));
|
||||
}
|
||||
|
||||
rb_iv_set(klass, "default_name", defNamesObj);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
|
||||
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
||||
wrapProperty(klass, Font::getDefaultColor(), "default_color", ColorType);
|
||||
rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName()));
|
||||
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -48,7 +48,7 @@ RB_METHOD(graphicsTransition)
|
|||
RB_UNUSED_PARAM;
|
||||
|
||||
int duration = 8;
|
||||
const char *filename = "";
|
||||
const char *filename = 0;
|
||||
int vague = 40;
|
||||
|
||||
rb_get_args(argc, argv, "|izi", &duration, &filename, &vague RB_ARG_END);
|
||||
|
@ -174,27 +174,6 @@ RB_METHOD(graphicsResizeScreen)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(graphicsReset)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
shState->graphics().reset();
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(graphicsPlayMovie)
|
||||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
const char *filename;
|
||||
rb_get_args(argc, argv, "z", &filename RB_ARG_END);
|
||||
|
||||
shState->graphics().playMovie(filename);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
DEF_GRA_PROP_I(FrameRate)
|
||||
DEF_GRA_PROP_I(FrameCount)
|
||||
DEF_GRA_PROP_I(Brightness)
|
||||
|
@ -217,8 +196,6 @@ void graphicsBindingInit()
|
|||
_rb_define_module_function(module, "transition", graphicsTransition);
|
||||
_rb_define_module_function(module, "frame_reset", graphicsFrameReset);
|
||||
|
||||
_rb_define_module_function(module, "__reset__", graphicsReset);
|
||||
|
||||
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
|
||||
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
|
||||
|
||||
|
@ -235,11 +212,6 @@ void graphicsBindingInit()
|
|||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
_rb_define_module_function(module, "play_movie", graphicsPlayMovie);
|
||||
}
|
||||
|
||||
INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" );
|
||||
INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" );
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -38,22 +38,17 @@ static int getButtonArg(int argc, VALUE *argv)
|
|||
{
|
||||
int num;
|
||||
|
||||
rb_check_argc(argc, 1);
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
ID sym;
|
||||
rb_get_args(argc, argv, "n", &sym RB_ARG_END);
|
||||
|
||||
if (FIXNUM_P(argv[0]))
|
||||
{
|
||||
num = FIX2INT(argv[0]);
|
||||
}
|
||||
else if (SYMBOL_P(argv[0]) && rgssVer >= 3)
|
||||
{
|
||||
VALUE symHash = getRbData()->buttoncodeHash;
|
||||
num = FIX2INT(rb_hash_lookup2(symHash, argv[0], INT2FIX(Input::None)));
|
||||
num = FIX2INT(rb_hash_lookup2(symHash, ID2SYM(sym), INT2FIX(Input::None)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: RMXP allows only few more types that
|
||||
// don't make sense (symbols in pre 3, floats)
|
||||
num = 0;
|
||||
rb_get_args(argc, argv, "i", &num RB_ARG_END);
|
||||
}
|
||||
|
||||
return num;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -33,17 +33,19 @@ RB_METHOD(planeInitialize)
|
|||
|
||||
setPrivateData(self, p);
|
||||
|
||||
p->initDynAttribs();
|
||||
p->setColor(new Color);
|
||||
p->setTone(new Tone);
|
||||
|
||||
wrapProperty(self, &p->getColor(), "color", ColorType);
|
||||
wrapProperty(self, &p->getTone(), "tone", ToneType);
|
||||
wrapNilProperty(self, "bitmap");
|
||||
wrapProperty(self, p->getColor(), "color", ColorType);
|
||||
wrapProperty(self, p->getTone(), "tone", ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, "bitmap")
|
||||
DEF_PROP_OBJ_VAL(Plane, Color, Color, "color")
|
||||
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, "tone")
|
||||
DEF_PROP_OBJ_NIL(Plane, Bitmap, Bitmap, "bitmap")
|
||||
DEF_PROP_OBJ(Plane, Color, Color, "color")
|
||||
DEF_PROP_OBJ(Plane, Tone, Tone, "tone")
|
||||
|
||||
DEF_PROP_I(Plane, OX)
|
||||
DEF_PROP_I(Plane, OY)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -37,26 +37,28 @@ RB_METHOD(spriteInitialize)
|
|||
setPrivateData(self, s);
|
||||
|
||||
/* Wrap property objects */
|
||||
s->initDynAttribs();
|
||||
s->setSrcRect(new Rect);
|
||||
s->setColor(new Color);
|
||||
s->setTone(new Tone);
|
||||
|
||||
wrapProperty(self, &s->getSrcRect(), "src_rect", RectType);
|
||||
wrapProperty(self, &s->getColor(), "color", ColorType);
|
||||
wrapProperty(self, &s->getTone(), "tone", ToneType);
|
||||
wrapNilProperty(self, "bitmap");
|
||||
wrapProperty(self, s->getSrcRect(), "src_rect", RectType);
|
||||
wrapProperty(self, s->getColor(), "color", ColorType);
|
||||
wrapProperty(self, s->getTone(), "tone", ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, "bitmap")
|
||||
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, "src_rect")
|
||||
DEF_PROP_OBJ_VAL(Sprite, Color, Color, "color")
|
||||
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, "tone")
|
||||
DEF_PROP_OBJ_NIL(Sprite, Bitmap, Bitmap, "bitmap")
|
||||
DEF_PROP_OBJ(Sprite, Rect, SrcRect, "src_rect")
|
||||
DEF_PROP_OBJ(Sprite, Color, Color, "color")
|
||||
DEF_PROP_OBJ(Sprite, Tone, Tone, "tone")
|
||||
|
||||
DEF_PROP_I(Sprite, X)
|
||||
DEF_PROP_I(Sprite, Y)
|
||||
DEF_PROP_I(Sprite, OX)
|
||||
DEF_PROP_I(Sprite, OY)
|
||||
DEF_PROP_I(Sprite, BushDepth)
|
||||
DEF_PROP_I(Sprite, BushOpacity)
|
||||
DEF_PROP_I(Sprite, Opacity)
|
||||
DEF_PROP_I(Sprite, BlendType)
|
||||
DEF_PROP_I(Sprite, WaveAmp)
|
||||
|
@ -127,8 +129,6 @@ spriteBindingInit()
|
|||
_rb_define_method(klass, "width", spriteWidth);
|
||||
_rb_define_method(klass, "height", spriteHeight);
|
||||
|
||||
INIT_PROP_BIND( Sprite, BushOpacity, "bush_opacity" );
|
||||
|
||||
INIT_PROP_BIND( Sprite, WaveAmp, "wave_amp" );
|
||||
INIT_PROP_BIND( Sprite, WaveLength, "wave_length" );
|
||||
INIT_PROP_BIND( Sprite, WaveSpeed, "wave_speed" );
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -94,10 +94,6 @@ RB_METHOD(tilemapInitialize)
|
|||
|
||||
rb_iv_set(autotilesObj, "array", ary);
|
||||
|
||||
/* Circular reference so both objects are always
|
||||
* alive at the same time */
|
||||
rb_iv_set(autotilesObj, "tilemap", self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -105,8 +101,6 @@ RB_METHOD(tilemapGetAutotiles)
|
|||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<Tilemap>(self);
|
||||
|
||||
return rb_iv_get(self, "autotiles");
|
||||
}
|
||||
|
||||
|
@ -125,15 +119,15 @@ RB_METHOD(tilemapGetViewport)
|
|||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<Tilemap>(self);
|
||||
checkDisposed(self);
|
||||
|
||||
return rb_iv_get(self, "viewport");
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Tilemap, Bitmap, Tileset, "tileset")
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, MapData, "map_data")
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, "flash_data")
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, "priorities")
|
||||
DEF_PROP_OBJ(Tilemap, Bitmap, Tileset, "tileset")
|
||||
DEF_PROP_OBJ(Tilemap, Table, MapData, "map_data")
|
||||
DEF_PROP_OBJ(Tilemap, Table, FlashData, "flash_data")
|
||||
DEF_PROP_OBJ(Tilemap, Table, Priorities, "priorities")
|
||||
|
||||
DEF_PROP_B(Tilemap, Visible)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -58,16 +58,12 @@ RB_METHOD(tilemapVXInitialize)
|
|||
|
||||
VALUE autotilesObj = rb_iv_get(self, "bitmap_array");
|
||||
|
||||
VALUE ary = rb_ary_new2(9);
|
||||
for (int i = 0; i < 9; ++i)
|
||||
VALUE ary = rb_ary_new2(7);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
rb_ary_push(ary, Qnil);
|
||||
|
||||
rb_iv_set(autotilesObj, "array", ary);
|
||||
|
||||
/* Circular reference so both objects are always
|
||||
* alive at the same time */
|
||||
rb_iv_set(autotilesObj, "tilemap", self);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -75,8 +71,6 @@ RB_METHOD(tilemapVXGetBitmapArray)
|
|||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<TilemapVX>(self);
|
||||
|
||||
return rb_iv_get(self, "bitmap_array");
|
||||
}
|
||||
|
||||
|
@ -91,10 +85,11 @@ RB_METHOD(tilemapVXUpdate)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(TilemapVX, Viewport, Viewport, "viewport")
|
||||
DEF_PROP_OBJ_REF(TilemapVX, Table, MapData, "map_data")
|
||||
DEF_PROP_OBJ_REF(TilemapVX, Table, FlashData, "flash_data")
|
||||
DEF_PROP_OBJ_REF(TilemapVX, Table, Flags, "flags")
|
||||
DEF_PROP_OBJ_NIL(TilemapVX, Viewport, Viewport, "viewport")
|
||||
|
||||
DEF_PROP_OBJ(TilemapVX, Table, MapData, "map_data")
|
||||
DEF_PROP_OBJ(TilemapVX, Table, FlashData, "flash_data")
|
||||
DEF_PROP_OBJ(TilemapVX, Table, Flags, "flags")
|
||||
|
||||
DEF_PROP_B(TilemapVX, Visible)
|
||||
|
||||
|
@ -125,7 +120,7 @@ RB_METHOD(tilemapVXBitmapsGet)
|
|||
int i;
|
||||
rb_get_args (argc, argv, "i", &i RB_ARG_END);
|
||||
|
||||
if (i < 0 || i > 8)
|
||||
if (i < 0 || i > 6)
|
||||
return Qnil;
|
||||
|
||||
VALUE ary = rb_iv_get(self, "array");
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -62,11 +62,13 @@ RB_METHOD(viewportInitialize)
|
|||
setPrivateData(self, v);
|
||||
|
||||
/* Wrap property objects */
|
||||
v->initDynAttribs();
|
||||
v->setRect(new Rect(*v->getRect()));
|
||||
v->setColor(new Color);
|
||||
v->setTone(new Tone);
|
||||
|
||||
wrapProperty(self, &v->getRect(), "rect", RectType);
|
||||
wrapProperty(self, &v->getColor(), "color", ColorType);
|
||||
wrapProperty(self, &v->getTone(), "tone", ToneType);
|
||||
wrapProperty(self, v->getRect(), "rect", RectType);
|
||||
wrapProperty(self, v->getColor(), "color", ColorType);
|
||||
wrapProperty(self, v->getTone(), "tone", ToneType);
|
||||
|
||||
/* 'elements' holds all SceneElements that become children
|
||||
* of this viewport, so we can dispose them when the viewport
|
||||
|
@ -76,9 +78,9 @@ RB_METHOD(viewportInitialize)
|
|||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, "rect")
|
||||
DEF_PROP_OBJ_VAL(Viewport, Color, Color, "color")
|
||||
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, "tone")
|
||||
DEF_PROP_OBJ(Viewport, Rect, Rect, "rect")
|
||||
DEF_PROP_OBJ(Viewport, Color, Color, "color")
|
||||
DEF_PROP_OBJ(Viewport, Tone, Tone, "tone")
|
||||
|
||||
DEF_PROP_I(Viewport, OX)
|
||||
DEF_PROP_I(Viewport, OY)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,7 +35,7 @@ RB_METHOD(viewportElementGetViewport)
|
|||
{
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
checkDisposed<C>(self);
|
||||
checkDisposed(self);
|
||||
|
||||
return rb_iv_get(self, "viewport");
|
||||
}
|
||||
|
@ -75,9 +75,7 @@ viewportElementInitialize(int argc, VALUE *argv, VALUE self)
|
|||
if (!NIL_P(viewportObj))
|
||||
{
|
||||
viewport = getPrivateDataCheck<Viewport>(viewportObj, ViewportType);
|
||||
|
||||
if (rgssVer == 1)
|
||||
disposableAddChild(viewportObj, self);
|
||||
disposableAddChild(viewportObj, self);
|
||||
}
|
||||
|
||||
/* Construct object */
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,9 +32,10 @@ RB_METHOD(windowInitialize)
|
|||
|
||||
setPrivateData(self, w);
|
||||
|
||||
w->initDynAttribs();
|
||||
|
||||
wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType);
|
||||
w->setCursorRect(new Rect);
|
||||
wrapNilProperty(self, "windowskin");
|
||||
wrapNilProperty(self, "contents");
|
||||
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -50,9 +51,9 @@ RB_METHOD(windowUpdate)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Window, Bitmap, Windowskin, "windowskin")
|
||||
DEF_PROP_OBJ_REF(Window, Bitmap, Contents, "contents")
|
||||
DEF_PROP_OBJ_VAL(Window, Rect, CursorRect, "cursor_rect")
|
||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Windowskin, "windowskin")
|
||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Contents, "contents")
|
||||
DEF_PROP_OBJ(Window, Rect, CursorRect, "cursor_rect")
|
||||
|
||||
DEF_PROP_B(Window, Stretch)
|
||||
DEF_PROP_B(Window, Active)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -51,17 +51,19 @@ RB_METHOD(windowVXInitialize)
|
|||
|
||||
setPrivateData(self, w);
|
||||
|
||||
w->initDynAttribs();
|
||||
w->setCursorRect(new Rect);
|
||||
w->setTone(new Tone);
|
||||
wrapNilProperty(self, "windowskin");
|
||||
wrapProperty(self, w->getTone(), "tone", ToneType);
|
||||
wrapProperty(self, w->getCursorRect(), "cursor_rect", RectType);
|
||||
|
||||
wrapProperty(self, &w->getCursorRect(), "cursor_rect", RectType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(self, &w->getTone(), "tone", ToneType);
|
||||
|
||||
Bitmap *contents = new Bitmap(1, 1);
|
||||
VALUE contentsObj = wrapObject(contents, BitmapType);
|
||||
bitmapInitProps(contents, contentsObj);
|
||||
rb_iv_set(self, "contents", contentsObj);
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
Bitmap *contents = new Bitmap(1, 1);
|
||||
VALUE contentsObj = wrapObject(contents, BitmapType);
|
||||
bitmapInitProps(contents, contentsObj);
|
||||
rb_iv_set(self, "contents", contentsObj);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -107,11 +109,11 @@ RB_METHOD(windowVXIsClosed)
|
|||
return rb_bool_new(w->isClosed());
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(WindowVX, Bitmap, Windowskin, "windowskin")
|
||||
DEF_PROP_OBJ_REF(WindowVX, Bitmap, Contents, "contents")
|
||||
DEF_PROP_OBJ_NIL(WindowVX, Bitmap, Windowskin, "windowskin")
|
||||
DEF_PROP_OBJ_NIL(WindowVX, Bitmap, Contents, "contents")
|
||||
|
||||
DEF_PROP_OBJ_VAL(WindowVX, Rect, CursorRect, "cursor_rect")
|
||||
DEF_PROP_OBJ_VAL(WindowVX, Tone, Tone, "tone")
|
||||
DEF_PROP_OBJ(WindowVX, Rect, CursorRect, "cursor_rect")
|
||||
DEF_PROP_OBJ(WindowVX, Tone, Tone, "tone")
|
||||
|
||||
DEF_PROP_I(WindowVX, X)
|
||||
DEF_PROP_I(WindowVX, Y)
|
||||
|
@ -140,12 +142,17 @@ windowVXBindingInit()
|
|||
viewportElementBindingInit<WindowVX>(klass);
|
||||
|
||||
_rb_define_method(klass, "initialize", windowVXInitialize);
|
||||
|
||||
_rb_define_method(klass, "update", windowVXUpdate);
|
||||
_rb_define_method(klass, "move", windowVXMove);
|
||||
_rb_define_method(klass, "open?", windowVXIsOpen);
|
||||
_rb_define_method(klass, "close?", windowVXIsClosed);
|
||||
|
||||
INIT_PROP_BIND( WindowVX, Windowskin, "windowskin" );
|
||||
INIT_PROP_BIND( WindowVX, Contents, "contents" );
|
||||
INIT_PROP_BIND( WindowVX, CursorRect, "cursor_rect" );
|
||||
INIT_PROP_BIND( WindowVX, Active, "active" );
|
||||
INIT_PROP_BIND( WindowVX, ArrowsVisible, "arrows_visible" );
|
||||
INIT_PROP_BIND( WindowVX, Pause, "pause" );
|
||||
INIT_PROP_BIND( WindowVX, X, "x" );
|
||||
INIT_PROP_BIND( WindowVX, Y, "y" );
|
||||
|
@ -153,20 +160,11 @@ windowVXBindingInit()
|
|||
INIT_PROP_BIND( WindowVX, Height, "height" );
|
||||
INIT_PROP_BIND( WindowVX, OX, "ox" );
|
||||
INIT_PROP_BIND( WindowVX, OY, "oy" );
|
||||
INIT_PROP_BIND( WindowVX, Padding, "padding" );
|
||||
INIT_PROP_BIND( WindowVX, PaddingBottom, "padding_bottom" );
|
||||
INIT_PROP_BIND( WindowVX, Opacity, "opacity" );
|
||||
INIT_PROP_BIND( WindowVX, BackOpacity, "back_opacity" );
|
||||
INIT_PROP_BIND( WindowVX, ContentsOpacity, "contents_opacity" );
|
||||
INIT_PROP_BIND( WindowVX, Openness, "openness" );
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
_rb_define_method(klass, "move", windowVXMove);
|
||||
_rb_define_method(klass, "open?", windowVXIsOpen);
|
||||
_rb_define_method(klass, "close?", windowVXIsClosed);
|
||||
|
||||
INIT_PROP_BIND( WindowVX, ArrowsVisible, "arrows_visible" );
|
||||
INIT_PROP_BIND( WindowVX, Padding, "padding" );
|
||||
INIT_PROP_BIND( WindowVX, PaddingBottom, "padding_bottom" );
|
||||
INIT_PROP_BIND( WindowVX, Tone, "tone" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -51,13 +51,11 @@
|
|||
|
||||
static void mrbBindingExecute();
|
||||
static void mrbBindingTerminate();
|
||||
static void mrbBindingReset();
|
||||
|
||||
ScriptBinding scriptBindingImpl =
|
||||
{
|
||||
mrbBindingExecute,
|
||||
mrbBindingTerminate,
|
||||
mrbBindingReset
|
||||
mrbBindingTerminate
|
||||
};
|
||||
|
||||
ScriptBinding *scriptBinding = &scriptBindingImpl;
|
||||
|
@ -114,17 +112,8 @@ static void mrbBindingInit(mrb_state *mrb)
|
|||
/* Load RPG module */
|
||||
mrb_load_irep(mrb, mrbModuleRPG);
|
||||
|
||||
/* Load global constants */
|
||||
mrb_define_global_const(mrb, "MKXP", mrb_true_value());
|
||||
|
||||
mrb_value debug = rb_bool_new(shState->config().editor.debug);
|
||||
if (rgssVer == 1)
|
||||
mrb_define_global_const(mrb, "DEBUG", debug);
|
||||
else if (rgssVer >= 2)
|
||||
mrb_define_global_const(mrb, "TEST", debug);
|
||||
|
||||
mrb_define_global_const(mrb, "BTEST", mrb_bool_value(shState->config().editor.battleTest));
|
||||
|
||||
mrb_gc_arena_restore(mrb, arena);
|
||||
}
|
||||
|
||||
|
@ -201,7 +190,7 @@ static void
|
|||
runCustomScript(mrb_state *mrb, mrbc_context *ctx, const char *filename)
|
||||
{
|
||||
/* Execute custom script */
|
||||
FILE *f = fopen(filename, "rb");
|
||||
FILE *f = fopen(filename, "r");
|
||||
|
||||
if (!f)
|
||||
{
|
||||
|
@ -226,7 +215,7 @@ static void
|
|||
runMrbFile(mrb_state *mrb, const char *filename)
|
||||
{
|
||||
/* Execute compiled script */
|
||||
FILE *f = fopen(filename, "rb");
|
||||
FILE *f = fopen(filename, "r");
|
||||
|
||||
if (!f)
|
||||
{
|
||||
|
@ -275,7 +264,7 @@ runRMXPScripts(mrb_state *mrb, mrbc_context *ctx)
|
|||
mrb_state *scriptMrb = mrb_open();
|
||||
SDL_RWops ops;
|
||||
|
||||
shState->fileSystem().openReadRaw(ops, scriptPack.c_str());
|
||||
shState->fileSystem().openRead(ops, scriptPack.c_str());
|
||||
|
||||
mrb_value scriptArray = mrb_nil_value();
|
||||
std::string readError;
|
||||
|
@ -395,7 +384,7 @@ static void mrbBindingExecute()
|
|||
|
||||
checkException(mrb);
|
||||
|
||||
shState->rtData().rqTermAck.set();
|
||||
shState->rtData().rqTermAck = true;
|
||||
shState->texPool().disable();
|
||||
|
||||
mrbc_context_free(mrb, ctx);
|
||||
|
@ -409,8 +398,3 @@ static void mrbBindingTerminate()
|
|||
|
||||
mrb_raise(mrb, data->exc[Shutdown], "");
|
||||
}
|
||||
|
||||
static void mrbBindingReset()
|
||||
{
|
||||
// No idea how to do this with mruby yet
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -37,11 +37,9 @@ struct
|
|||
SYMD(viewport),
|
||||
SYMD(bitmap),
|
||||
SYMD(color),
|
||||
SYMD(out_color),
|
||||
SYMD(tone),
|
||||
SYMD(rect),
|
||||
SYMD(src_rect),
|
||||
SYMD(tilemap),
|
||||
SYMD(tileset),
|
||||
SYMD(autotiles),
|
||||
SYMD(map_data),
|
||||
|
@ -53,9 +51,8 @@ struct
|
|||
SYMD(path),
|
||||
SYMD(array),
|
||||
SYMD(default_color),
|
||||
SYMD(default_out_color),
|
||||
SYMD(children),
|
||||
SYMD(_mkxp_dispose_alias)
|
||||
SYMD(dispose)
|
||||
};
|
||||
|
||||
static elementsN(symData);
|
||||
|
@ -69,6 +66,7 @@ struct MrbExcData
|
|||
static const MrbExcData excData[] =
|
||||
{
|
||||
{ Shutdown, "SystemExit" },
|
||||
{ RGSS, "RGSSError" },
|
||||
{ PHYSFS, "PHYSFSError" },
|
||||
{ SDL, "SDLError" },
|
||||
{ MKXP, "MKXPError" },
|
||||
|
@ -108,8 +106,6 @@ MrbData::MrbData(mrb_state *mrb)
|
|||
for (size_t i = 0; i < excDataN; ++i)
|
||||
exc[excData[i].ind] = mrb_define_class(mrb, excData[i].str, mrb->eException_class);
|
||||
|
||||
exc[RGSS] = mrb_define_class(mrb, "RGSSError", mrb->eStandardError_class);
|
||||
|
||||
RClass *errnoMod = mrb_define_module(mrb, "Errno");
|
||||
|
||||
for (size_t i = 0; i < enoExcDataN; ++i)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -38,11 +38,9 @@ enum CommonSymbol
|
|||
CSviewport,
|
||||
CSbitmap,
|
||||
CScolor,
|
||||
CSout_color,
|
||||
CStone,
|
||||
CSrect,
|
||||
CSsrc_rect,
|
||||
CStilemap,
|
||||
CStileset,
|
||||
CSautotiles,
|
||||
CSmap_data,
|
||||
|
@ -54,9 +52,8 @@ enum CommonSymbol
|
|||
CSpath,
|
||||
CSarray,
|
||||
CSdefault_color,
|
||||
CSdefault_out_color,
|
||||
CSchildren,
|
||||
CS_mkxp_dispose_alias,
|
||||
CSdispose,
|
||||
|
||||
CommonSymbolsMax
|
||||
};
|
||||
|
@ -152,11 +149,10 @@ defineClass(mrb_state *mrb, const char *name)
|
|||
|
||||
#define MRB_FUN_UNUSED_PARAM { (void) mrb; }
|
||||
|
||||
/* Object property which is copied by value, not reference */
|
||||
#define DEF_PROP_OBJ_VAL(Klass, PropKlass, PropName, prop_iv) \
|
||||
#define DEF_PROP_OBJ(Klass, PropKlass, PropName, prop_iv) \
|
||||
MRB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
checkDisposed<Klass>(mrb, self); \
|
||||
checkDisposed(mrb, self); \
|
||||
return getProperty(mrb, self, prop_iv); \
|
||||
} \
|
||||
MRB_METHOD(Klass##Set##PropName) \
|
||||
|
@ -166,12 +162,13 @@ defineClass(mrb_state *mrb, const char *name)
|
|||
PropKlass *prop; \
|
||||
mrb_get_args(mrb, "o", &propObj); \
|
||||
prop = getPrivateDataCheck<PropKlass>(mrb, propObj, PropKlass##Type); \
|
||||
GUARD_EXC( k->set##PropName(*prop); ) \
|
||||
GUARD_EXC( k->set##PropName(prop); ) \
|
||||
setProperty(mrb, self, prop_iv, propObj); \
|
||||
return propObj; \
|
||||
}
|
||||
|
||||
/* Object property which is copied by reference, with allowed NIL */
|
||||
#define DEF_PROP_OBJ_REF(Klass, PropKlass, PropName, prop_iv) \
|
||||
/* Object property with allowed NIL */
|
||||
#define DEF_PROP_OBJ_NIL(Klass, PropKlass, PropName, prop_iv) \
|
||||
MRB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
return getProperty(mrb, self, prop_iv); \
|
||||
|
@ -195,9 +192,7 @@ defineClass(mrb_state *mrb, const char *name)
|
|||
MRB_METHOD(Klass##Get##PropName) \
|
||||
{ \
|
||||
Klass *k = getPrivateData<Klass>(mrb, self); \
|
||||
mrb_type value = 0; \
|
||||
GUARD_EXC( value = k->get##PropName(); ) \
|
||||
return mrb_##conv_t##_value(value); \
|
||||
return mrb_##conv_t##_value(k->get##PropName()); \
|
||||
} \
|
||||
MRB_METHOD(Klass##Set##PropName) \
|
||||
{ \
|
||||
|
@ -259,12 +254,21 @@ getSym(mrb_state *mrb, CommonSymbol sym)
|
|||
void
|
||||
raiseDisposedAccess(mrb_state *mrb, mrb_value self);
|
||||
|
||||
inline void checkDisposed(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
if (!DATA_PTR(self))
|
||||
raiseDisposedAccess(mrb, self);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
inline C *
|
||||
getPrivateData(mrb_state *, mrb_value self)
|
||||
getPrivateData(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
C *c = static_cast<C*>(DATA_PTR(self));
|
||||
|
||||
if (!c)
|
||||
raiseDisposedAccess(mrb, self);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -296,7 +300,7 @@ wrapObject(mrb_state *mrb, void *p, const mrb_data_type &type)
|
|||
return obj;
|
||||
}
|
||||
|
||||
inline mrb_value
|
||||
inline void
|
||||
wrapProperty(mrb_state *mrb, mrb_value self,
|
||||
void *prop, CommonSymbol iv, const mrb_data_type &type)
|
||||
{
|
||||
|
@ -306,8 +310,15 @@ wrapProperty(mrb_state *mrb, mrb_value self,
|
|||
mrb_obj_ptr(self),
|
||||
getSym(mrb, iv),
|
||||
propObj);
|
||||
}
|
||||
|
||||
return propObj;
|
||||
inline void
|
||||
wrapNilProperty(mrb_state *mrb, mrb_value self, CommonSymbol iv)
|
||||
{
|
||||
mrb_obj_iv_set(mrb,
|
||||
mrb_obj_ptr(self),
|
||||
getSym(mrb, iv),
|
||||
mrb_nil_value());
|
||||
}
|
||||
|
||||
inline mrb_value
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,7 +22,6 @@
|
|||
#include "bitmap.h"
|
||||
#include "font.h"
|
||||
#include "exception.h"
|
||||
#include "sharedstate.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
|
@ -52,15 +51,11 @@ MRB_METHOD(bitmapInitialize)
|
|||
|
||||
/* Wrap properties */
|
||||
Font *font = new Font();
|
||||
b->setInitFont(font);
|
||||
font->initDynAttribs();
|
||||
b->setFont(font);
|
||||
font->setColor(new Color(*font->getColor()));
|
||||
|
||||
mrb_value fontProp = wrapProperty(mrb, self, font, CSfont, FontType);
|
||||
|
||||
wrapProperty(mrb, fontProp, &font->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, fontProp, &font->getOutColor(), CSout_color, ColorType);
|
||||
wrapProperty(mrb, self, font, CSfont, FontType);
|
||||
wrapProperty(mrb, getProperty(mrb, self, CSfont), font->getColor(), CScolor, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -114,7 +109,7 @@ MRB_METHOD(bitmapBlt)
|
|||
src = getPrivateDataCheck<Bitmap>(mrb, srcObj, BitmapType);
|
||||
srcRect = getPrivateDataCheck<Rect>(mrb, srcRectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->blt(x, y, *src, srcRect->toIntRect(), opacity); )
|
||||
GUARD_EXC( b->blt(x, y, src, srcRect->toIntRect(), opacity); )
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
@ -137,7 +132,7 @@ MRB_METHOD(bitmapStretchBlt)
|
|||
destRect = getPrivateDataCheck<Rect>(mrb, destRectObj, RectType);
|
||||
srcRect = getPrivateDataCheck<Rect>(mrb, srcRectObj, RectType);
|
||||
|
||||
GUARD_EXC( b->stretchBlt(destRect->toIntRect(), *src, srcRect->toIntRect(), opacity); )
|
||||
GUARD_EXC( b->stretchBlt(destRect->toIntRect(), src, srcRect->toIntRect(), opacity); )
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
@ -280,7 +275,7 @@ MRB_METHOD(bitmapTextSize)
|
|||
|
||||
MRB_METHOD(bitmapGetFont)
|
||||
{
|
||||
checkDisposed<Bitmap>(mrb, self);
|
||||
checkDisposed(mrb, self);
|
||||
|
||||
return getProperty(mrb, self, CSfont);
|
||||
}
|
||||
|
@ -296,7 +291,8 @@ MRB_METHOD(bitmapSetFont)
|
|||
|
||||
font = getPrivateDataCheck<Font>(mrb, fontObj, FontType);
|
||||
|
||||
GUARD_EXC( b->setFont(*font); )
|
||||
GUARD_EXC( b->setFont(font); )
|
||||
setProperty(mrb, self, CSfont, fontObj);
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -60,58 +60,39 @@ disposableDisposeChildren(mrb_state *mrb, mrb_value disp)
|
|||
|
||||
for (mrb_int i = 0; i < RARRAY_LEN(children); ++i)
|
||||
mrb_funcall_argv(mrb, mrb_ary_entry(children, i),
|
||||
mrbData->symbols[CS_mkxp_dispose_alias], 0, 0);
|
||||
mrbData->symbols[CSdispose], 0, 0);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
MRB_METHOD(disposableDispose)
|
||||
{
|
||||
C *d = static_cast<C*>(DATA_PTR(self));
|
||||
C *c = static_cast<C*>(DATA_PTR(self));
|
||||
|
||||
if (!d)
|
||||
/* Nothing to do if already disposed */
|
||||
if (!c)
|
||||
return mrb_nil_value();
|
||||
|
||||
if (d->isDisposed())
|
||||
return mrb_nil_value();
|
||||
disposableDisposeChildren(mrb, self);
|
||||
|
||||
if (rgssVer == 1)
|
||||
disposableDisposeChildren(mrb, self);
|
||||
|
||||
d->dispose();
|
||||
delete c;
|
||||
DATA_PTR(self) = 0;
|
||||
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
||||
template<class C>
|
||||
MRB_METHOD(disposableIsDisposed)
|
||||
MRB_METHOD(disposableDisposed)
|
||||
{
|
||||
MRB_UNUSED_PARAM;
|
||||
|
||||
C *d = static_cast<C*>(DATA_PTR(self));
|
||||
|
||||
if (!d)
|
||||
return mrb_true_value();
|
||||
|
||||
return mrb_bool_value(d->isDisposed());
|
||||
return mrb_bool_value(DATA_PTR(self) == 0);
|
||||
}
|
||||
|
||||
template<class C>
|
||||
static void disposableBindingInit(mrb_state *mrb, RClass *klass)
|
||||
{
|
||||
mrb_define_method(mrb, klass, "dispose", disposableDispose<C>, MRB_ARGS_NONE());
|
||||
mrb_define_method(mrb, klass, "disposed?", disposableIsDisposed<C>, MRB_ARGS_NONE());
|
||||
|
||||
if (rgssVer == 1)
|
||||
mrb_alias_method(mrb, klass, getMrbData(mrb)->symbols[CS_mkxp_dispose_alias],
|
||||
mrb_intern_lit(mrb, "dispose"));
|
||||
}
|
||||
|
||||
template<class C>
|
||||
inline void
|
||||
checkDisposed(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
if (mrb_test(disposableIsDisposed<C>(0, self)))
|
||||
raiseDisposedAccess(mrb, self);
|
||||
mrb_define_method(mrb, klass, "disposed?", disposableDisposed<C>, MRB_ARGS_NONE());
|
||||
}
|
||||
|
||||
#endif // DISPOSABLEBINDING_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
#include "font.h"
|
||||
#include "sharedstate.h"
|
||||
#include "binding-util.h"
|
||||
#include "binding-types.h"
|
||||
#include "exception.h"
|
||||
|
@ -54,12 +53,8 @@ MRB_METHOD(fontInitialize)
|
|||
setPrivateData(self, f, FontType);
|
||||
|
||||
/* Wrap property objects */
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, &f->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, self, &f->getOutColor(), CSout_color, ColorType);
|
||||
f->setColor(new Color(*f->getColor()));
|
||||
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -74,12 +69,8 @@ MRB_METHOD(fontInitializeCopy)
|
|||
setPrivateData(self, f, FontType);
|
||||
|
||||
/* Wrap property objects */
|
||||
f->initDynAttribs();
|
||||
|
||||
wrapProperty(mrb, self, &f->getColor(), CScolor, ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
wrapProperty(mrb, self, &f->getOutColor(), CSout_color, ColorType);
|
||||
f->setColor(new Color(*f->getColor()));
|
||||
wrapProperty(mrb, self, f->getColor(), CScolor, ColorType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -103,16 +94,10 @@ MRB_METHOD(FontSetName)
|
|||
return name;
|
||||
}
|
||||
|
||||
template<class C>
|
||||
static void checkDisposed(mrb_state *, mrb_value) {}
|
||||
|
||||
DEF_PROP_I(Font, Size)
|
||||
DEF_PROP_B(Font, Bold)
|
||||
DEF_PROP_B(Font, Italic)
|
||||
DEF_PROP_B(Font, Outline)
|
||||
DEF_PROP_B(Font, Shadow)
|
||||
DEF_PROP_OBJ_VAL(Font, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Font, Color, OutColor, CSout_color)
|
||||
DEF_PROP_OBJ(Font, Color, Color, CScolor)
|
||||
|
||||
#define DEF_KLASS_PROP(Klass, mrb_type, PropName, arg_type, conv_t) \
|
||||
static mrb_value \
|
||||
|
@ -129,11 +114,9 @@ DEF_PROP_OBJ_VAL(Font, Color, OutColor, CSout_color)
|
|||
return mrb_##conv_t##_value(value); \
|
||||
}
|
||||
|
||||
DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultOutline, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultShadow, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_int, DefaultSize, "i", fixnum)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultBold, "b", bool)
|
||||
DEF_KLASS_PROP(Font, mrb_bool, DefaultItalic, "b", bool)
|
||||
|
||||
MRB_FUNCTION(FontGetDefaultName)
|
||||
{
|
||||
|
@ -157,33 +140,13 @@ MRB_METHOD(FontGetDefaultColor)
|
|||
|
||||
MRB_METHOD(FontSetDefaultColor)
|
||||
{
|
||||
MRB_UNUSED_PARAM;
|
||||
|
||||
mrb_value colorObj;
|
||||
mrb_get_args(mrb, "o", &colorObj);
|
||||
|
||||
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
|
||||
|
||||
Font::setDefaultColor(*c);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
||||
MRB_METHOD(FontGetDefaultOutColor)
|
||||
{
|
||||
return getProperty(mrb, self, CSdefault_out_color);
|
||||
}
|
||||
|
||||
MRB_METHOD(FontSetDefaultOutColor)
|
||||
{
|
||||
MRB_UNUSED_PARAM;
|
||||
|
||||
mrb_value colorObj;
|
||||
mrb_get_args(mrb, "o", &colorObj);
|
||||
|
||||
Color *c = getPrivateDataCheck<Color>(mrb, colorObj, ColorType);
|
||||
|
||||
Font::setDefaultOutColor(*c);
|
||||
Font::setDefaultColor(c);
|
||||
setProperty(mrb, self, CSdefault_color, colorObj);
|
||||
|
||||
return colorObj;
|
||||
}
|
||||
|
@ -199,48 +162,25 @@ fontBindingInit(mrb_state *mrb)
|
|||
{
|
||||
RClass *klass = defineClass(mrb, "Font");
|
||||
|
||||
Font::initDefaultDynAttribs();
|
||||
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||
Font::setDefaultColor(new Color(*Font::getDefaultColor()));
|
||||
wrapProperty(mrb, mrb_obj_value(klass), Font::getDefaultColor(), CSdefault_color, ColorType);
|
||||
|
||||
mrb_define_class_method(mrb, klass, "exist?", fontDoesExist, MRB_ARGS_REQ(1));
|
||||
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
|
||||
wrapProperty(mrb, mrb_obj_value(klass), &Font::getDefaultOutColor(), CSdefault_out_color, ColorType);
|
||||
}
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultName, "default_name");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultSize, "default_size");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultBold, "default_bold");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
|
||||
mrb_define_method(mrb, klass, "initialize", fontInitialize, MRB_ARGS_OPT(2));
|
||||
mrb_define_method(mrb, klass, "initialize_copy", fontInitializeCopy, MRB_ARGS_REQ(1));
|
||||
|
||||
INIT_PROP_BIND(Font, Name, "name");
|
||||
INIT_PROP_BIND(Font, Size, "size");
|
||||
INIT_PROP_BIND(Font, Bold, "bold");
|
||||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
|
||||
if (rgssVer >= 2)
|
||||
{
|
||||
INIT_PROP_BIND(Font, Shadow, "shadow");
|
||||
}
|
||||
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
INIT_PROP_BIND(Font, Outline, "outline");
|
||||
INIT_PROP_BIND(Font, OutColor, "out_color");
|
||||
}
|
||||
INIT_PROP_BIND(Font, Name, "name");
|
||||
INIT_PROP_BIND(Font, Size, "size");
|
||||
INIT_PROP_BIND(Font, Bold, "bold");
|
||||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
|
||||
mrb_define_method(mrb, klass, "inspect", inspectObject, MRB_ARGS_NONE());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -45,7 +45,7 @@ MRB_FUNCTION(graphicsFreeze)
|
|||
MRB_FUNCTION(graphicsTransition)
|
||||
{
|
||||
mrb_int duration = 8;
|
||||
const char *filename = "";
|
||||
const char *filename = 0;
|
||||
mrb_int vague = 40;
|
||||
|
||||
mrb_get_args(mrb, "|izi", &duration, &filename, &vague);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -40,26 +40,20 @@ MRB_FUNCTION(inputUpdate)
|
|||
static mrb_int getButtonArg(mrb_state *mrb)
|
||||
{
|
||||
mrb_int num;
|
||||
mrb_value arg;
|
||||
|
||||
mrb_get_args(mrb, "o", &arg);
|
||||
if (rgssVer >= 3)
|
||||
{
|
||||
mrb_sym sym;
|
||||
mrb_get_args(mrb, "n", &sym);
|
||||
|
||||
if (mrb_fixnum_p(arg))
|
||||
{
|
||||
num = mrb_fixnum(arg);
|
||||
}
|
||||
else if (mrb_symbol_p(arg) && rgssVer >= 3)
|
||||
{
|
||||
mrb_value symHash = getMrbData(mrb)->buttoncodeHash;
|
||||
mrb_value numVal = mrb_hash_fetch(mrb, symHash, arg,
|
||||
mrb_value numVal = mrb_hash_fetch(mrb, symHash, mrb_symbol_value(sym),
|
||||
mrb_fixnum_value(Input::None));
|
||||
num = mrb_fixnum(numVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: RMXP allows only few more types that
|
||||
// don't make sense (symbols in pre 3, floats)
|
||||
num = 0;
|
||||
mrb_get_args(mrb, "i", &num);
|
||||
}
|
||||
|
||||
return num;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
#include "rwmem.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <SDL_rwops.h>
|
||||
|
||||
|
@ -102,7 +101,7 @@ int RWMemGetData(SDL_RWops *ops, void *buffer)
|
|||
ByteVec *v = getRWPrivate(ops);
|
||||
|
||||
if (buffer)
|
||||
memcpy(buffer, dataPtr(*v), v->size());
|
||||
memcpy(buffer, &(*v)[0], v->size());
|
||||
|
||||
return v->size();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -33,17 +33,19 @@ MRB_METHOD(planeInitialize)
|
|||
|
||||
setPrivateData(self, p, PlaneType);
|
||||
|
||||
p->initDynAttribs();
|
||||
p->setColor(new Color);
|
||||
p->setTone(new Tone);
|
||||
|
||||
wrapProperty(mrb, self, &p->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &p->getTone(), CStone, ToneType);
|
||||
wrapNilProperty(mrb, self, CSbitmap);
|
||||
wrapProperty(mrb, self, p->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, p->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Plane, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ_VAL(Plane, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Plane, Tone, Tone, CStone)
|
||||
DEF_PROP_OBJ(Plane, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ(Plane, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ(Plane, Tone, Tone, CStone)
|
||||
|
||||
DEF_PROP_I(Plane, OX)
|
||||
DEF_PROP_I(Plane, OY)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
#include "sprite.h"
|
||||
#include "sharedstate.h"
|
||||
#include "disposable-binding.h"
|
||||
#include "flashable-binding.h"
|
||||
#include "sceneelement-binding.h"
|
||||
|
@ -36,19 +35,22 @@ MRB_METHOD(spriteInitialize)
|
|||
setPrivateData(self, s, SpriteType);
|
||||
|
||||
/* Wrap property objects */
|
||||
s->initDynAttribs();
|
||||
s->setSrcRect(new Rect);
|
||||
s->setColor(new Color);
|
||||
s->setTone(new Tone);
|
||||
|
||||
wrapProperty(mrb, self, &s->getSrcRect(), CSsrc_rect, RectType);
|
||||
wrapProperty(mrb, self, &s->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &s->getTone(), CStone, ToneType);
|
||||
wrapNilProperty(mrb, self, CSbitmap);
|
||||
wrapProperty(mrb, self, s->getSrcRect(), CSsrc_rect, RectType);
|
||||
wrapProperty(mrb, self, s->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, s->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Sprite, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ_VAL(Sprite, Rect, SrcRect, CSsrc_rect)
|
||||
DEF_PROP_OBJ_VAL(Sprite, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Sprite, Tone, Tone, CStone)
|
||||
DEF_PROP_OBJ_NIL(Sprite, Bitmap, Bitmap, CSbitmap)
|
||||
DEF_PROP_OBJ(Sprite, Rect, SrcRect, CSsrc_rect)
|
||||
DEF_PROP_OBJ(Sprite, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ(Sprite, Tone, Tone, CStone)
|
||||
|
||||
DEF_PROP_I(Sprite, X)
|
||||
DEF_PROP_I(Sprite, Y)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -93,26 +93,19 @@ MRB_METHOD(tilemapInitialize)
|
|||
|
||||
wrapProperty(mrb, self, &t->getAutotiles(), CSautotiles, TilemapAutotilesType);
|
||||
|
||||
MrbData &mrbData = *getMrbData(mrb);
|
||||
mrb_value autotilesObj = mrb_iv_get(mrb, self, mrbData.symbols[CSautotiles]);
|
||||
mrb_value autotilesObj = mrb_iv_get(mrb, self, getMrbData(mrb)->symbols[CSautotiles]);
|
||||
|
||||
mrb_value ary = mrb_ary_new_capa(mrb, 7);
|
||||
for (int i = 0; i < 7; ++i)
|
||||
mrb_ary_push(mrb, ary, mrb_nil_value());
|
||||
|
||||
mrb_iv_set(mrb, autotilesObj, mrbData.symbols[CSarray], ary);
|
||||
|
||||
/* Circular reference so both objects are always
|
||||
* alive at the same time */
|
||||
mrb_iv_set(mrb, autotilesObj, mrbData.symbols[CStilemap], self);
|
||||
mrb_iv_set(mrb, autotilesObj, getMrbData(mrb)->symbols[CSarray], ary);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
MRB_METHOD(tilemapGetAutotiles)
|
||||
{
|
||||
checkDisposed<Tilemap>(mrb, self);
|
||||
|
||||
return getProperty(mrb, self, CSautotiles);
|
||||
}
|
||||
|
||||
|
@ -127,15 +120,15 @@ MRB_METHOD(tilemapUpdate)
|
|||
|
||||
MRB_METHOD(tilemapGetViewport)
|
||||
{
|
||||
checkDisposed<Tilemap>(mrb, self);
|
||||
checkDisposed(mrb, self);
|
||||
|
||||
return getProperty(mrb, self, CSviewport);
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Tilemap, Bitmap, Tileset, CStileset)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, MapData, CSmap_data)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, FlashData, CSflash_data)
|
||||
DEF_PROP_OBJ_REF(Tilemap, Table, Priorities, CSpriorities)
|
||||
DEF_PROP_OBJ(Tilemap, Bitmap, Tileset, CStileset)
|
||||
DEF_PROP_OBJ(Tilemap, Table, MapData, CSmap_data)
|
||||
DEF_PROP_OBJ(Tilemap, Table, FlashData, CSflash_data)
|
||||
DEF_PROP_OBJ(Tilemap, Table, Priorities, CSpriorities)
|
||||
|
||||
DEF_PROP_B(Tilemap, Visible)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -57,18 +57,20 @@ MRB_METHOD(viewportInitialize)
|
|||
setPrivateData(self, v, ViewportType);
|
||||
|
||||
/* Wrap property objects */
|
||||
v->initDynAttribs();
|
||||
v->setRect(new Rect(*v->getRect()));
|
||||
v->setColor(new Color);
|
||||
v->setTone(new Tone);
|
||||
|
||||
wrapProperty(mrb, self, &v->getRect(), CSrect, RectType);
|
||||
wrapProperty(mrb, self, &v->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, &v->getTone(), CStone, ToneType);
|
||||
wrapProperty(mrb, self, v->getRect(), CSrect, RectType);
|
||||
wrapProperty(mrb, self, v->getColor(), CScolor, ColorType);
|
||||
wrapProperty(mrb, self, v->getTone(), CStone, ToneType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_VAL(Viewport, Rect, Rect, CSrect)
|
||||
DEF_PROP_OBJ_VAL(Viewport, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ_VAL(Viewport, Tone, Tone, CStone)
|
||||
DEF_PROP_OBJ(Viewport, Rect, Rect, CSrect)
|
||||
DEF_PROP_OBJ(Viewport, Color, Color, CScolor)
|
||||
DEF_PROP_OBJ(Viewport, Tone, Tone, CStone)
|
||||
|
||||
DEF_PROP_I(Viewport, OX)
|
||||
DEF_PROP_I(Viewport, OY)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,7 +32,7 @@
|
|||
template<class C>
|
||||
MRB_METHOD(viewportElementGetViewport)
|
||||
{
|
||||
checkDisposed<C>(mrb, self);
|
||||
checkDisposed(mrb, self);
|
||||
|
||||
return getProperty(mrb, self, CSviewport);
|
||||
}
|
||||
|
@ -50,9 +50,7 @@ viewportElementInitialize(mrb_state *mrb, mrb_value self)
|
|||
if (!mrb_nil_p(viewportObj))
|
||||
{
|
||||
viewport = getPrivateDataCheck<Viewport>(mrb, viewportObj, ViewportType);
|
||||
|
||||
if (rgssVer == 1)
|
||||
disposableAddChild(mrb, viewportObj, self);
|
||||
disposableAddChild(mrb, viewportObj, self);
|
||||
}
|
||||
|
||||
/* Construct object */
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -32,8 +32,10 @@ MRB_METHOD(windowInitialize)
|
|||
|
||||
setPrivateData(self, w, WindowType);
|
||||
|
||||
w->initDynAttribs();
|
||||
wrapProperty(mrb, self, &w->getCursorRect(), CScursor_rect, RectType);
|
||||
w->setCursorRect(new Rect);
|
||||
wrapNilProperty(mrb, self, CSwindowskin);
|
||||
wrapNilProperty(mrb, self, CScontents);
|
||||
wrapProperty(mrb, self, w->getCursorRect(), CScursor_rect, RectType);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -47,9 +49,9 @@ MRB_METHOD(windowUpdate)
|
|||
return mrb_nil_value();
|
||||
}
|
||||
|
||||
DEF_PROP_OBJ_REF(Window, Bitmap, Windowskin, CSwindowskin)
|
||||
DEF_PROP_OBJ_REF(Window, Bitmap, Contents, CScontents)
|
||||
DEF_PROP_OBJ_VAL(Window, Rect, CursorRect, CScursor_rect)
|
||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Windowskin, CSwindowskin)
|
||||
DEF_PROP_OBJ_NIL(Window, Bitmap, Contents, CScontents)
|
||||
DEF_PROP_OBJ(Window, Rect, CursorRect, CScursor_rect)
|
||||
|
||||
DEF_PROP_B(Window, Stretch)
|
||||
DEF_PROP_B(Window, Active)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,7 +27,7 @@
|
|||
static void nullBindingExecute()
|
||||
{
|
||||
Debug() << "The null binding doesn't do anything, so we're done!";
|
||||
shState->rtData().rqTermAck.set();
|
||||
shState->rtData().rqTermAck = true;
|
||||
}
|
||||
|
||||
static void nullBindingTerminate()
|
||||
|
@ -35,16 +35,10 @@ static void nullBindingTerminate()
|
|||
|
||||
}
|
||||
|
||||
static void nullBindingReset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ScriptBinding scriptBindingImpl =
|
||||
{
|
||||
nullBindingExecute,
|
||||
nullBindingTerminate,
|
||||
nullBindingReset
|
||||
nullBindingTerminate
|
||||
};
|
||||
|
||||
ScriptBinding *scriptBinding = &scriptBindingImpl;
|
||||
|
|
102
mkxp.conf.sample
102
mkxp.conf.sample
|
@ -1,14 +1,4 @@
|
|||
# Lines starting with '#' are comments.
|
||||
#
|
||||
# About filesystem paths specified in this config:
|
||||
# The "gameFolder" path is resolved either relative
|
||||
# to the directory containing the mkxp executable
|
||||
# (the default behavior), or relative to the current
|
||||
# working directory (when compiled with
|
||||
# -DWORKDIR_CURRENT). All other paths are resolved
|
||||
# relative to gameFolder and ignoring both RTPs and
|
||||
# encrypted archives.
|
||||
|
||||
# Lines starting with '#' are comments
|
||||
|
||||
# Specify the RGSS version to run under.
|
||||
# Possible values are 0, 1, 2, 3. If set to 0,
|
||||
|
@ -27,14 +17,6 @@
|
|||
# debugMode=false
|
||||
|
||||
|
||||
# Continuously print average FPS to console.
|
||||
# This setting does not affect the window title
|
||||
# FPS display toggled via F2
|
||||
# (default: disabled)
|
||||
#
|
||||
# printFPS=false
|
||||
|
||||
|
||||
# Game window is resizable
|
||||
# (default: disabled)
|
||||
#
|
||||
|
@ -57,9 +39,9 @@
|
|||
|
||||
# Apply linear interpolation when game screen
|
||||
# is upscaled
|
||||
# (default: enabled)
|
||||
# (default: disabled)
|
||||
#
|
||||
# smoothScaling=true
|
||||
# smoothScaling=false
|
||||
|
||||
|
||||
# Sync screen redraws to the monitor refresh rate
|
||||
|
@ -86,12 +68,6 @@
|
|||
# defScreenH=480
|
||||
|
||||
|
||||
# Override the game window title
|
||||
# (default: none)
|
||||
#
|
||||
# windowTitle=Custom Title
|
||||
|
||||
|
||||
# Enforce a static frame rate
|
||||
# (0 = disabled)
|
||||
#
|
||||
|
@ -104,52 +80,12 @@
|
|||
# frameSkip=true
|
||||
|
||||
|
||||
# Use a fixed framerate that is approx. equal to the
|
||||
# native screen refresh rate. This is different from
|
||||
# "fixedFramerate" because the actual frame rate is
|
||||
# reported back to the game, ensuring correct timers.
|
||||
# If the screen refresh rate cannot be determined,
|
||||
# this option is force-disabled
|
||||
# (default: disabled)
|
||||
#
|
||||
# syncToRefreshrate=false
|
||||
|
||||
|
||||
# Don't use alpha blending when rendering text
|
||||
# (default: disabled)
|
||||
#
|
||||
# solidFonts=false
|
||||
|
||||
|
||||
# Work around buggy graphics drivers which don't
|
||||
# properly synchronize texture access, most
|
||||
# apparent when text doesn't show up or the map
|
||||
# tileset doesn't render at all
|
||||
# (default: disabled)
|
||||
#
|
||||
# subImageFix=false
|
||||
|
||||
|
||||
# Enable framebuffer blitting if the driver is
|
||||
# capable of it. Some drivers carry buggy
|
||||
# implementations of this functionality, so
|
||||
# disabling it can be used as a workaround
|
||||
# (default: enabled)
|
||||
#
|
||||
# enableBlitting=true
|
||||
|
||||
|
||||
# Limit the maximum size (width, height) of
|
||||
# most textures mkxp will create (exceptions are
|
||||
# rendering backbuffers and similar).
|
||||
# If set to 0, the hardware maximum is used.
|
||||
# This is useful for recording traces that can
|
||||
# be played back on machines with lower specs.
|
||||
# (default: 0)
|
||||
#
|
||||
# maxTextureSize=0
|
||||
|
||||
|
||||
# Set the base path of the game to '/path/to/game'
|
||||
# (default: executable directory)
|
||||
#
|
||||
|
@ -163,31 +99,12 @@
|
|||
# anyAltToggleFS=false
|
||||
|
||||
|
||||
# Enable F12 game reset
|
||||
# (default: enabled)
|
||||
#
|
||||
# enableReset=true
|
||||
|
||||
|
||||
# Allow symlinks for game assets to be followed
|
||||
# (default: disabled)
|
||||
#
|
||||
# allowSymlinks=false
|
||||
|
||||
|
||||
# Organisation / company and application / game
|
||||
# name to build the directory path where mkxp
|
||||
# will store game specific data (eg. key bindings).
|
||||
# If not specified, mkxp will save to a common
|
||||
# directory shared by all games. Note that these
|
||||
# are TWO individual config entries, and both need
|
||||
# to be defined for this to take effect.
|
||||
# (default: none)
|
||||
#
|
||||
# dataPathOrg=mycompany
|
||||
# dataPathApp=mygame
|
||||
|
||||
|
||||
# Set the game window icon to 'path/to/icon.png'
|
||||
# (default: none)
|
||||
#
|
||||
|
@ -282,19 +199,6 @@
|
|||
# SE.sourceCount=6
|
||||
|
||||
|
||||
# The Windows game executable name minus ".exe". By default
|
||||
# this is "Game", but some developers manually rename it.
|
||||
# mkxp needs this name because both the .ini (game
|
||||
# configuration) and .rgssad (encrypted data archive) must
|
||||
# carry the same name minus their extension, and we cannot
|
||||
# guess the executable's name.
|
||||
# You could just as well rename them both to "Game.ini" and
|
||||
# "Game.rgssad", but specifying the executable name here
|
||||
# is a tiny bit less intrusive.
|
||||
#
|
||||
# execName=Game
|
||||
|
||||
|
||||
# Give a hint on which language the game title as
|
||||
# specified in the Game.ini is, useful if the encoding
|
||||
# is being falsely detected. Relevant only if mkxp was
|
||||
|
|
54
mkxp.pro
54
mkxp.pro
|
@ -8,9 +8,11 @@ INCLUDEPATH += . src
|
|||
|
||||
CONFIG(release, debug|release): DEFINES += NDEBUG
|
||||
|
||||
CONFIG += c++11
|
||||
# And for older qmake versions..
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
CONFIG += MIDI
|
||||
|
||||
DISABLE_MIDI {
|
||||
CONFIG -= MIDI
|
||||
}
|
||||
|
||||
isEmpty(BINDING) {
|
||||
BINDING = MRI
|
||||
|
@ -48,7 +50,7 @@ unix {
|
|||
PKGCONFIG += sigc++-2.0 pixman-1 zlib physfs vorbisfile \
|
||||
sdl2 SDL2_image SDL2_ttf SDL_sound openal
|
||||
|
||||
SHARED_FLUID {
|
||||
MIDI {
|
||||
PKGCONFIG += fluidsynth
|
||||
}
|
||||
|
||||
|
@ -93,7 +95,6 @@ HEADERS += \
|
|||
src/flashable.h \
|
||||
src/font.h \
|
||||
src/input.h \
|
||||
src/iniconfig.h \
|
||||
src/plane.h \
|
||||
src/scene.h \
|
||||
src/sprite.h \
|
||||
|
@ -108,9 +109,8 @@ HEADERS += \
|
|||
src/glstate.h \
|
||||
src/quad.h \
|
||||
src/tilemap.h \
|
||||
src/tilemap-common.h \
|
||||
src/graphics.h \
|
||||
src/gl-debug.h \
|
||||
src/debuglogger.h \
|
||||
src/global-ibo.h \
|
||||
src/exception.h \
|
||||
src/filesystem.h \
|
||||
|
@ -120,8 +120,6 @@ HEADERS += \
|
|||
src/gl-util.h \
|
||||
src/util.h \
|
||||
src/config.h \
|
||||
src/settingsmenu.h \
|
||||
src/keybindings.h \
|
||||
src/tileatlas.h \
|
||||
src/sharedstate.h \
|
||||
src/al-util.h \
|
||||
|
@ -137,10 +135,7 @@ HEADERS += \
|
|||
src/rgssad.h \
|
||||
src/windowvx.h \
|
||||
src/tilemapvx.h \
|
||||
src/tileatlasvx.h \
|
||||
src/sharedmidistate.h \
|
||||
src/fluid-fun.h \
|
||||
src/sdl-util.h
|
||||
src/tileatlasvx.h
|
||||
|
||||
SOURCES += \
|
||||
src/main.cpp \
|
||||
|
@ -150,7 +145,6 @@ SOURCES += \
|
|||
src/filesystem.cpp \
|
||||
src/font.cpp \
|
||||
src/input.cpp \
|
||||
src/iniconfig.cpp \
|
||||
src/plane.cpp \
|
||||
src/scene.cpp \
|
||||
src/sprite.cpp \
|
||||
|
@ -164,11 +158,9 @@ SOURCES += \
|
|||
src/tilemap.cpp \
|
||||
src/autotiles.cpp \
|
||||
src/graphics.cpp \
|
||||
src/gl-debug.cpp \
|
||||
src/debuglogger.cpp \
|
||||
src/etc.cpp \
|
||||
src/config.cpp \
|
||||
src/settingsmenu.cpp \
|
||||
src/keybindings.cpp \
|
||||
src/tileatlas.cpp \
|
||||
src/sharedstate.cpp \
|
||||
src/gl-fun.cpp \
|
||||
|
@ -184,26 +176,19 @@ SOURCES += \
|
|||
src/windowvx.cpp \
|
||||
src/tilemapvx.cpp \
|
||||
src/tileatlasvx.cpp \
|
||||
src/autotilesvx.cpp \
|
||||
src/midisource.cpp \
|
||||
src/fluid-fun.cpp
|
||||
src/autotilesvx.cpp
|
||||
|
||||
EMBED = \
|
||||
shader/common.h \
|
||||
shader/transSimple.frag \
|
||||
shader/trans.frag \
|
||||
shader/hue.frag \
|
||||
shader/sprite.frag \
|
||||
shader/plane.frag \
|
||||
shader/gray.frag \
|
||||
shader/bitmapBlit.frag \
|
||||
shader/flatColor.frag \
|
||||
shader/simple.frag \
|
||||
shader/simpleColor.frag \
|
||||
shader/simpleAlpha.frag \
|
||||
shader/simpleAlphaUni.frag \
|
||||
shader/flashMap.frag \
|
||||
shader/minimal.vert \
|
||||
shader/simple.vert \
|
||||
shader/simpleColor.vert \
|
||||
shader/sprite.vert \
|
||||
|
@ -213,11 +198,16 @@ EMBED = \
|
|||
shader/blurV.vert \
|
||||
shader/simpleMatrix.vert \
|
||||
shader/tilemapvx.vert \
|
||||
assets/liberation.ttf \
|
||||
assets/icon.png
|
||||
assets/liberation.ttf
|
||||
|
||||
SHARED_FLUID {
|
||||
DEFINES += SHARED_FLUID
|
||||
MIDI {
|
||||
HEADERS += \
|
||||
src/sharedmidistate.h
|
||||
|
||||
SOURCES += \
|
||||
src/midisource.cpp
|
||||
|
||||
DEFINES += MIDI
|
||||
}
|
||||
|
||||
INI_ENCODING {
|
||||
|
@ -284,11 +274,7 @@ BINDING_MRUBY {
|
|||
}
|
||||
|
||||
BINDING_MRI {
|
||||
isEmpty(MRIVERSION) {
|
||||
MRIVERSION = 2.1
|
||||
}
|
||||
|
||||
PKGCONFIG += ruby-$$MRIVERSION
|
||||
PKGCONFIG += ruby-2.1
|
||||
DEFINES += BINDING_MRI
|
||||
|
||||
# EMBED2 = binding-mri/module_rpg.rb
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
diff -r 719dade41745 Makefile.am
|
||||
--- a/Makefile.am Wed Aug 15 23:52:18 2012 -0400
|
||||
+++ b/Makefile.am Thu Nov 28 18:42:40 2013 +0100
|
||||
@@ -1,8 +1,8 @@
|
||||
lib_LTLIBRARIES = libSDL_sound.la
|
||||
|
||||
-SUBDIRS = decoders . playsound
|
||||
+SUBDIRS = decoders .
|
||||
|
||||
-libSDL_soundincludedir = $(includedir)/SDL
|
||||
+libSDL_soundincludedir = $(includedir)/SDL2
|
||||
libSDL_soundinclude_HEADERS = \
|
||||
SDL_sound.h
|
||||
|
||||
@@ -49,3 +49,5 @@
|
||||
echo >> $(distdir)/docs/README
|
||||
rm -rf `find $(distdir) -type d -name ".svn"`
|
||||
|
||||
+pkgconfigdir = $(libdir)/pkgconfig
|
||||
+pkgconfig_DATA = SDL_sound.pc
|
||||
diff -r 719dade41745 SDL_sound.pc.in
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/SDL_sound.pc.in Thu Nov 28 18:42:40 2013 +0100
|
||||
@@ -0,0 +1,11 @@
|
||||
+prefix=@prefix@
|
||||
+exec_prefix=@exec_prefix@
|
||||
+libdir=@libdir@
|
||||
+includedir=@includedir@
|
||||
+
|
||||
+Name: SDL_sound
|
||||
+Description: audio decoding library for Simple DirectMedia Layer
|
||||
+Version: @VERSION@
|
||||
+Requires: sdl2 >= @SDL_VERSION@
|
||||
+Libs: -L${libdir} -lSDL_sound
|
||||
+Cflags: -I${includedir}/SDL2
|
||||
diff -r 719dade41745 configure.in
|
||||
--- a/configure.in Wed Aug 15 23:52:18 2012 -0400
|
||||
+++ b/configure.in Thu Nov 28 18:42:40 2013 +0100
|
||||
@@ -107,7 +107,8 @@
|
||||
dnl ---------------------------------------------------------------------
|
||||
|
||||
dnl Check for SDL
|
||||
-SDL_VERSION=1.2.0
|
||||
+SDL_VERSION=2.0.0
|
||||
+AC_SUBST(SDL_VERSION)
|
||||
AM_PATH_SDL($SDL_VERSION,
|
||||
:,
|
||||
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
|
||||
@@ -339,4 +340,5 @@
|
||||
decoders/timidity/Makefile
|
||||
decoders/libmpg123/Makefile
|
||||
playsound/Makefile
|
||||
+SDL_sound.pc
|
||||
])
|
|
@ -1,43 +0,0 @@
|
|||
--- a/common.mk
|
||||
+++ b/common.mk
|
||||
@@ -95,6 +95,7 @@ COMMONOBJS = array.$(OBJEXT) \
|
||||
vm_trace.$(OBJEXT) \
|
||||
thread.$(OBJEXT) \
|
||||
cont.$(OBJEXT) \
|
||||
+ ext/zlib/zlib.$(OBJEXT) \
|
||||
$(BUILTIN_ENCOBJS) \
|
||||
$(BUILTIN_TRANSOBJS) \
|
||||
$(MISSING)
|
||||
diff --git a/ruby-2.1.5.orig/configure b/ruby-2.1.5/configure
|
||||
index d0f1f68..45ab642 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -2838,6 +2838,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
|
||||
|
||||
|
||||
|
||||
+LIBS="$LIBS -lz"
|
||||
+
|
||||
{ # environment section
|
||||
|
||||
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -31,6 +31,8 @@ rm() {
|
||||
}
|
||||
])])])
|
||||
|
||||
+LIBS="$LIBS -lz"
|
||||
+
|
||||
{ # environment section
|
||||
|
||||
AC_ARG_WITH(baseruby,
|
||||
--- a/inits.c
|
||||
+++ b/inits.c
|
||||
@@ -61,5 +61,6 @@ rb_call_inits(void)
|
||||
CALL(Complex);
|
||||
CALL(version);
|
||||
CALL(vm_trace);
|
||||
+ CALL(zlib);
|
||||
}
|
||||
#undef CALL
|
|
@ -6,7 +6,7 @@ uniform sampler2D destination;
|
|||
|
||||
uniform vec4 subRect;
|
||||
|
||||
uniform lowp float opacity;
|
||||
uniform float opacity;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ varying vec2 v_blurCoord[2];
|
|||
|
||||
void main()
|
||||
{
|
||||
lowp vec4 frag = vec4(0, 0, 0, 0);
|
||||
vec4 frag = vec4(0, 0, 0, 0);
|
||||
|
||||
frag += texture2D(texture, v_texCoord);
|
||||
frag += texture2D(texture, v_blurCoord[0]);
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#ifdef GLSLES
|
||||
|
||||
#ifdef FRAGMENT_SHADER
|
||||
/* Only the fragment shader has no default float precision */
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/* Desktop GLSL doesn't know about these */
|
||||
#define highp
|
||||
#define mediump
|
||||
#define lowp
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
uniform lowp float alpha;
|
||||
uniform float alpha;
|
||||
|
||||
varying lowp vec4 v_color;
|
||||
varying vec4 v_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
uniform lowp vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
uniform sampler2D texture;
|
||||
uniform lowp float gray;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
const vec3 lumaF = vec3(.299, .587, .114);
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Sample source color */
|
||||
vec4 frag = texture2D(texture, v_texCoord);
|
||||
|
||||
/* Apply gray */
|
||||
float luma = dot(frag.rgb, lumaF);
|
||||
frag.rgb = mix(frag.rgb, vec3(luma), gray);
|
||||
|
||||
gl_FragColor = frag;
|
||||
}
|
|
@ -1,40 +1,44 @@
|
|||
|
||||
uniform sampler2D texture;
|
||||
uniform mediump float hueAdjust;
|
||||
uniform sampler2D inputTexture;
|
||||
uniform float hueAdjust;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
/* Source: gamedev.stackexchange.com/a/59808/24839 */
|
||||
vec3 rgb2hsv(vec3 c)
|
||||
{
|
||||
const vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
||||
float d = q.x - min(q.w, q.y);
|
||||
|
||||
/* Avoid divide-by-zero situations by adding a very tiny delta.
|
||||
* Since we always deal with underlying 8-Bit color values, this
|
||||
* should never mask a real value */
|
||||
const float eps = 1.0e-10;
|
||||
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + eps)), d / (q.x + eps), q.x);
|
||||
}
|
||||
|
||||
vec3 hsv2rgb(vec3 c)
|
||||
{
|
||||
const vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec4 color = texture2D (texture, v_texCoord.xy);
|
||||
vec3 hsv = rgb2hsv(color.rgb);
|
||||
const vec4 kRGBToYPrime = vec4 (0.299, 0.587, 0.114, 0.0);
|
||||
const vec4 kRGBToI = vec4 (0.596, -0.275, -0.321, 0.0);
|
||||
const vec4 kRGBToQ = vec4 (0.212, -0.523, 0.311, 0.0);
|
||||
|
||||
hsv.x += hueAdjust;
|
||||
color.rgb = hsv2rgb(hsv);
|
||||
const vec4 kYIQToR = vec4 (1.0, 0.956, 0.621, 0.0);
|
||||
const vec4 kYIQToG = vec4 (1.0, -0.272, -0.647, 0.0);
|
||||
const vec4 kYIQToB = vec4 (1.0, -1.107, 1.704, 0.0);
|
||||
|
||||
/* Sample the input pixel */
|
||||
vec4 color = texture2D (inputTexture, v_texCoord.xy);
|
||||
|
||||
/* Convert to YIQ */
|
||||
float YPrime = dot (color, kRGBToYPrime);
|
||||
float I = dot (color, kRGBToI);
|
||||
float Q = dot (color, kRGBToQ);
|
||||
|
||||
/* Calculate the hue and chroma */
|
||||
float hue = atan (Q, I);
|
||||
float chroma = sqrt (I * I + Q * Q);
|
||||
|
||||
/* Make the user's adjustments */
|
||||
hue += hueAdjust;
|
||||
|
||||
// Convert back to YIQ
|
||||
Q = chroma * sin (hue);
|
||||
I = chroma * cos (hue);
|
||||
|
||||
/* Convert back to RGB */
|
||||
vec4 yIQ = vec4 (YPrime, I, Q, 0.0);
|
||||
color.r = dot (yIQ, kYIQToR);
|
||||
color.g = dot (yIQ, kYIQToG);
|
||||
color.b = dot (yIQ, kYIQToB);
|
||||
|
||||
/* Save the result */
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
|
||||
uniform mat4 projMat;
|
||||
attribute vec2 position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projMat * vec4(position, 0, 1);
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
uniform sampler2D texture;
|
||||
|
||||
uniform lowp vec4 tone;
|
||||
uniform vec4 tone;
|
||||
|
||||
uniform lowp float opacity;
|
||||
uniform lowp vec4 color;
|
||||
uniform lowp vec4 flash;
|
||||
uniform float opacity;
|
||||
uniform vec4 color;
|
||||
uniform vec4 flash;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
uniform sampler2D texture;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
varying lowp vec4 v_color;
|
||||
varying vec4 v_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
uniform sampler2D texture;
|
||||
uniform lowp float alpha;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(texture, v_texCoord);
|
||||
gl_FragColor.a *= alpha;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
varying lowp vec4 v_color;
|
||||
varying vec4 v_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -6,10 +6,10 @@ uniform vec2 translation;
|
|||
|
||||
attribute vec2 position;
|
||||
attribute vec2 texCoord;
|
||||
attribute lowp vec4 color;
|
||||
attribute vec4 color;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
varying lowp vec4 v_color;
|
||||
varying vec4 v_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -6,10 +6,10 @@ uniform vec2 texSizeInv;
|
|||
|
||||
attribute vec2 position;
|
||||
attribute vec2 texCoord;
|
||||
attribute lowp vec4 color;
|
||||
attribute vec4 color;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
varying lowp vec4 v_color;
|
||||
varying vec4 v_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
|
||||
uniform sampler2D texture;
|
||||
|
||||
uniform lowp vec4 tone;
|
||||
uniform vec4 tone;
|
||||
|
||||
uniform lowp float opacity;
|
||||
uniform lowp vec4 color;
|
||||
uniform float opacity;
|
||||
uniform vec4 color;
|
||||
|
||||
uniform float bushDepth;
|
||||
uniform lowp float bushOpacity;
|
||||
uniform float bushOpacity;
|
||||
|
||||
varying vec2 v_texCoord;
|
||||
|
||||
|
@ -32,7 +32,7 @@ void main()
|
|||
frag.rgb = mix(frag.rgb, color.rgb, color.a);
|
||||
|
||||
/* Apply bush alpha by mathematical if */
|
||||
lowp float underBush = float(v_texCoord.y < bushDepth);
|
||||
float underBush = float(v_texCoord.y < bushDepth);
|
||||
frag.a *= clamp(bushOpacity + underBush, 0.0, 1.0);
|
||||
|
||||
gl_FragColor = frag;
|
||||
|
|
|
@ -18,9 +18,8 @@ const float atAniOffset = 32.0*3.0;
|
|||
void main()
|
||||
{
|
||||
vec2 tex = texCoord;
|
||||
|
||||
lowp float pred = float(tex.x <= atAreaW && tex.y <= atAreaH);
|
||||
tex.x += aniIndex * atAniOffset * pred;
|
||||
if (tex.x <= atAreaW && tex.y <= atAreaH)
|
||||
tex.x += aniIndex * atAniOffset;
|
||||
|
||||
gl_Position = projMat * vec4(position + translation, 0, 1);
|
||||
|
||||
|
|
|
@ -18,15 +18,14 @@ const float atAreaCW = 4.0*32.0;
|
|||
void main()
|
||||
{
|
||||
vec2 tex = texCoord;
|
||||
lowp float pred;
|
||||
|
||||
/* Type A autotiles shift horizontally */
|
||||
pred = float(tex.x <= atAreaA.x && tex.y <= atAreaA.y);
|
||||
tex.x += aniOffset.x * pred;
|
||||
if (tex.x <= atAreaA.x && tex.y <= atAreaA.y)
|
||||
tex.x += aniOffset.x;
|
||||
|
||||
/* Type C autotiles shift vertically */
|
||||
pred = float(tex.x >= atAreaCX && tex.x <= (atAreaCX+atAreaCW) && tex.y <= atAreaA.y);
|
||||
tex.y += aniOffset.y * pred;
|
||||
if (tex.x >= atAreaCX && tex.x <= (atAreaCX+atAreaCW) && tex.y <= atAreaA.y)
|
||||
tex.y += aniOffset.y;
|
||||
|
||||
gl_Position = projMat * vec4(position + translation, 0, 1);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ void main()
|
|||
{
|
||||
float transV = texture2D(transMap, v_texCoord).r;
|
||||
float cTransV = clamp(transV, prog, prog+vague);
|
||||
lowp float alpha = (cTransV - prog) / vague;
|
||||
float alpha = (cTransV - prog) / vague;
|
||||
|
||||
vec4 newFrag = texture2D(currentScene, v_texCoord);
|
||||
vec4 oldFrag = texture2D(frozenScene, v_texCoord);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -238,6 +238,5 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount)
|
|||
|
||||
#define AUDIO_SLEEP 10
|
||||
#define STREAM_BUF_SIZE 32768
|
||||
#define GLOBAL_VOLUME 0.8f
|
||||
|
||||
#endif // ALUTIL_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -61,7 +61,9 @@ ALDataSource *createSDLSource(SDL_RWops &ops,
|
|||
ALDataSource *createVorbisSource(SDL_RWops &ops,
|
||||
bool looped);
|
||||
|
||||
#ifdef MIDI
|
||||
ALDataSource *createMidiSource(SDL_RWops &ops,
|
||||
bool looped);
|
||||
#endif
|
||||
|
||||
#endif // ALDATASOURCE_H
|
||||
|
|
144
src/alstream.cpp
144
src/alstream.cpp
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,14 +22,8 @@
|
|||
#include "alstream.h"
|
||||
|
||||
#include "sharedstate.h"
|
||||
#include "sharedmidistate.h"
|
||||
#include "eventthread.h"
|
||||
#include "filesystem.h"
|
||||
#include "exception.h"
|
||||
#include "aldatasource.h"
|
||||
#include "fluid-fun.h"
|
||||
#include "sdl-util.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#include <SDL_mutex.h>
|
||||
#include <SDL_thread.h>
|
||||
|
@ -42,12 +36,14 @@ ALStream::ALStream(LoopMode loopMode,
|
|||
source(0),
|
||||
thread(0),
|
||||
preemptPause(false),
|
||||
pitch(1.0f)
|
||||
streamInited(false),
|
||||
needsRewind(false),
|
||||
pitch(1.0)
|
||||
{
|
||||
alSrc = AL::Source::gen();
|
||||
|
||||
AL::Source::setVolume(alSrc, 1.0f);
|
||||
AL::Source::setPitch(alSrc, 1.0f);
|
||||
AL::Source::setVolume(alSrc, 1.0);
|
||||
AL::Source::setPitch(alSrc, 1.0);
|
||||
AL::Source::detachBuffer(alSrc);
|
||||
|
||||
for (int i = 0; i < STREAM_BUFS; ++i)
|
||||
|
@ -125,9 +121,6 @@ void ALStream::stop()
|
|||
|
||||
void ALStream::play(float offset)
|
||||
{
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
checkStopped();
|
||||
|
||||
switch (state)
|
||||
|
@ -172,7 +165,7 @@ void ALStream::setPitch(float value)
|
|||
/* If the source supports setting pitch natively,
|
||||
* we don't have to do it via OpenAL */
|
||||
if (source && source->setPitch(value))
|
||||
AL::Source::setPitch(alSrc, 1.0f);
|
||||
AL::Source::setPitch(alSrc, 1.0);
|
||||
else
|
||||
AL::Source::setPitch(alSrc, value);
|
||||
}
|
||||
|
@ -199,87 +192,52 @@ void ALStream::closeSource()
|
|||
delete source;
|
||||
}
|
||||
|
||||
struct ALStreamOpenHandler : FileSystem::OpenHandler
|
||||
{
|
||||
SDL_RWops *srcOps;
|
||||
bool looped;
|
||||
ALDataSource *source;
|
||||
std::string errorMsg;
|
||||
|
||||
ALStreamOpenHandler(SDL_RWops &srcOps, bool looped)
|
||||
: srcOps(&srcOps), looped(looped), source(0)
|
||||
{}
|
||||
|
||||
bool tryRead(SDL_RWops &ops, const char *ext)
|
||||
{
|
||||
/* Copy this because we need to keep it around,
|
||||
* as we will continue reading data from it later */
|
||||
*srcOps = ops;
|
||||
|
||||
/* Try to read ogg file signature */
|
||||
char sig[5] = { 0 };
|
||||
SDL_RWread(srcOps, sig, 1, 4);
|
||||
SDL_RWseek(srcOps, 0, RW_SEEK_SET);
|
||||
|
||||
try
|
||||
{
|
||||
if (!strcmp(sig, "OggS"))
|
||||
{
|
||||
source = createVorbisSource(*srcOps, looped);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!strcmp(sig, "MThd"))
|
||||
{
|
||||
shState->midiState().initIfNeeded(shState->config());
|
||||
|
||||
if (HAVE_FLUID)
|
||||
{
|
||||
source = createMidiSource(*srcOps, looped);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
source = createSDLSource(*srcOps, ext, STREAM_BUF_SIZE, looped);
|
||||
}
|
||||
catch (const Exception &e)
|
||||
{
|
||||
/* All source constructors will close the passed ops
|
||||
* before throwing errors */
|
||||
errorMsg = e.msg;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void ALStream::openSource(const std::string &filename)
|
||||
{
|
||||
ALStreamOpenHandler handler(srcOps, looped);
|
||||
shState->fileSystem().openRead(handler, filename.c_str());
|
||||
source = handler.source;
|
||||
needsRewind.clear();
|
||||
const char *ext;
|
||||
shState->fileSystem().openRead(srcOps, filename.c_str(), FileSystem::Audio, false, &ext);
|
||||
needsRewind = false;
|
||||
|
||||
if (!source)
|
||||
bool readSig = rgssVer >= 2;
|
||||
|
||||
#ifdef MIDI
|
||||
readSig = true;
|
||||
#endif
|
||||
|
||||
if (readSig)
|
||||
{
|
||||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "Unable to decode audio stream: %s: %s",
|
||||
filename.c_str(), handler.errorMsg.c_str());
|
||||
/* Try to read ogg file signature */
|
||||
char sig[5] = { 0 };
|
||||
SDL_RWread(&srcOps, sig, 1, 4);
|
||||
SDL_RWseek(&srcOps, 0, RW_SEEK_SET);
|
||||
|
||||
Debug() << buf;
|
||||
if (!strcmp(sig, "OggS"))
|
||||
{
|
||||
source = createVorbisSource(srcOps, looped);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MIDI
|
||||
if (!strcmp(sig, "MThd"))
|
||||
{
|
||||
source = createMidiSource(srcOps, looped);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
source = createSDLSource(srcOps, ext, STREAM_BUF_SIZE, looped);
|
||||
}
|
||||
|
||||
void ALStream::stopStream()
|
||||
{
|
||||
threadTermReq.set();
|
||||
threadTermReq = true;
|
||||
|
||||
if (thread)
|
||||
{
|
||||
SDL_WaitThread(thread, 0);
|
||||
thread = 0;
|
||||
needsRewind.set();
|
||||
needsRewind = true;
|
||||
}
|
||||
|
||||
/* Need to stop the source _after_ the thread has terminated,
|
||||
|
@ -295,15 +253,14 @@ void ALStream::startStream(float offset)
|
|||
AL::Source::clearQueue(alSrc);
|
||||
|
||||
preemptPause = false;
|
||||
streamInited.clear();
|
||||
sourceExhausted.clear();
|
||||
threadTermReq.clear();
|
||||
streamInited = false;
|
||||
sourceExhausted = false;
|
||||
threadTermReq = false;
|
||||
|
||||
startOffset = offset;
|
||||
procFrames = offset * source->sampleRate();
|
||||
|
||||
thread = createSDLThread
|
||||
<ALStream, &ALStream::streamData>(this, threadName);
|
||||
thread = SDL_CreateThread(streamDataFun, threadName.c_str(), this);
|
||||
}
|
||||
|
||||
void ALStream::pauseStream()
|
||||
|
@ -391,7 +348,7 @@ void ALStream::streamData()
|
|||
resumeStream();
|
||||
|
||||
firstBuffer = false;
|
||||
streamInited.set();
|
||||
streamInited = true;
|
||||
}
|
||||
|
||||
if (threadTermReq)
|
||||
|
@ -399,7 +356,7 @@ void ALStream::streamData()
|
|||
|
||||
if (status == ALDataSource::EndOfStream)
|
||||
{
|
||||
sourceExhausted.set();
|
||||
sourceExhausted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -408,8 +365,6 @@ void ALStream::streamData()
|
|||
* refill and queue them up again */
|
||||
while (true)
|
||||
{
|
||||
shState->rtData().syncPoint.passSecondarySync();
|
||||
|
||||
ALint procBufs = AL::Source::getProcBufferCount(alSrc);
|
||||
|
||||
while (procBufs--)
|
||||
|
@ -449,7 +404,7 @@ void ALStream::streamData()
|
|||
|
||||
if (status == ALDataSource::Error)
|
||||
{
|
||||
sourceExhausted.set();
|
||||
sourceExhausted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -468,7 +423,7 @@ void ALStream::streamData()
|
|||
lastBuf = buf;
|
||||
|
||||
if (status == ALDataSource::EndOfStream)
|
||||
sourceExhausted.set();
|
||||
sourceExhausted = true;
|
||||
}
|
||||
|
||||
if (threadTermReq)
|
||||
|
@ -477,3 +432,10 @@ void ALStream::streamData()
|
|||
SDL_Delay(AUDIO_SLEEP);
|
||||
}
|
||||
}
|
||||
|
||||
int ALStream::streamDataFun(void *_self)
|
||||
{
|
||||
ALStream &self = *static_cast<ALStream*>(_self);
|
||||
self.streamData();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -23,11 +23,12 @@
|
|||
#define ALSTREAM_H
|
||||
|
||||
#include "al-util.h"
|
||||
#include "sdl-util.h"
|
||||
|
||||
#include <string>
|
||||
#include <SDL_rwops.h>
|
||||
|
||||
struct SDL_mutex;
|
||||
struct SDL_thread;
|
||||
struct ALDataSource;
|
||||
|
||||
#define STREAM_BUFS 3
|
||||
|
@ -58,12 +59,12 @@ struct ALStream
|
|||
/* When this flag isn't set and alSrc is
|
||||
* in 'STOPPED' state, stream isn't over
|
||||
* (it just hasn't started yet) */
|
||||
AtomicFlag streamInited;
|
||||
AtomicFlag sourceExhausted;
|
||||
bool streamInited;
|
||||
bool sourceExhausted;
|
||||
|
||||
AtomicFlag threadTermReq;
|
||||
bool threadTermReq;
|
||||
|
||||
AtomicFlag needsRewind;
|
||||
bool needsRewind;
|
||||
float startOffset;
|
||||
|
||||
float pitch;
|
||||
|
@ -117,6 +118,7 @@ private:
|
|||
|
||||
/* thread func */
|
||||
void streamData();
|
||||
static int streamDataFun(void *);
|
||||
};
|
||||
|
||||
#endif // ALSTREAM_H
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,9 +24,10 @@
|
|||
#include "audiostream.h"
|
||||
#include "soundemitter.h"
|
||||
#include "sharedstate.h"
|
||||
|
||||
#ifdef MIDI
|
||||
#include "sharedmidistate.h"
|
||||
#include "eventthread.h"
|
||||
#include "sdl-util.h"
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -41,8 +42,6 @@ struct AudioPrivate
|
|||
|
||||
SoundEmitter se;
|
||||
|
||||
SyncPoint &syncPoint;
|
||||
|
||||
/* The 'MeWatch' is responsible for detecting
|
||||
* a playing ME, quickly fading out the BGM and
|
||||
* keeping it paused/stopped while the ME plays,
|
||||
|
@ -59,37 +58,36 @@ struct AudioPrivate
|
|||
struct
|
||||
{
|
||||
SDL_Thread *thread;
|
||||
AtomicFlag termReq;
|
||||
bool active;
|
||||
bool termReq;
|
||||
MeWatchState state;
|
||||
} meWatch;
|
||||
|
||||
AudioPrivate(RGSSThreadData &rtData)
|
||||
AudioPrivate(const Config &conf)
|
||||
: bgm(ALStream::Looped, "bgm"),
|
||||
bgs(ALStream::Looped, "bgs"),
|
||||
me(ALStream::NotLooped, "me"),
|
||||
se(rtData.config),
|
||||
syncPoint(rtData.syncPoint)
|
||||
se(conf)
|
||||
{
|
||||
meWatch.active = false;
|
||||
meWatch.termReq = false;
|
||||
meWatch.state = MeNotPlaying;
|
||||
meWatch.thread = createSDLThread
|
||||
<AudioPrivate, &AudioPrivate::meWatchFun>(this, "audio_mewatch");
|
||||
meWatch.thread = SDL_CreateThread(meWatchFun, "audio_mewatch", this);
|
||||
}
|
||||
|
||||
~AudioPrivate()
|
||||
{
|
||||
meWatch.termReq.set();
|
||||
meWatch.termReq = true;
|
||||
SDL_WaitThread(meWatch.thread, 0);
|
||||
}
|
||||
|
||||
void meWatchFun()
|
||||
void meWatchFunInt()
|
||||
{
|
||||
const float fadeOutStep = 1.f / (200 / AUDIO_SLEEP);
|
||||
const float fadeInStep = 1.f / (1000 / AUDIO_SLEEP);
|
||||
|
||||
while (true)
|
||||
{
|
||||
syncPoint.passSecondarySync();
|
||||
|
||||
if (meWatch.termReq)
|
||||
return;
|
||||
|
||||
|
@ -126,13 +124,13 @@ struct AudioPrivate
|
|||
|
||||
bgm.lockStream();
|
||||
|
||||
float vol = bgm.getVolume(AudioStream::External);
|
||||
float vol = bgm.extVolume;
|
||||
vol -= fadeOutStep;
|
||||
|
||||
if (vol < 0 || bgm.stream.queryState() != ALStream::Playing)
|
||||
{
|
||||
/* Either BGM has fully faded out, or stopped midway. -> MePlaying */
|
||||
bgm.setVolume(AudioStream::External, 0);
|
||||
bgm.setExtVolume1(0);
|
||||
bgm.stream.pause();
|
||||
meWatch.state = MePlaying;
|
||||
bgm.unlockStream();
|
||||
|
@ -141,7 +139,7 @@ struct AudioPrivate
|
|||
break;
|
||||
}
|
||||
|
||||
bgm.setVolume(AudioStream::External, vol);
|
||||
bgm.setExtVolume1(vol);
|
||||
bgm.unlockStream();
|
||||
me.unlockStream();
|
||||
|
||||
|
@ -170,7 +168,7 @@ struct AudioPrivate
|
|||
else
|
||||
{
|
||||
/* BGM is stopped. -> MeNotPlaying */
|
||||
bgm.setVolume(AudioStream::External, 1.0f);
|
||||
bgm.setExtVolume1(1.0);
|
||||
|
||||
if (!bgm.noResumeStop)
|
||||
bgm.stream.play();
|
||||
|
@ -193,7 +191,7 @@ struct AudioPrivate
|
|||
if (bgm.stream.queryState() == ALStream::Stopped)
|
||||
{
|
||||
/* BGM stopped midway fade in. -> MeNotPlaying */
|
||||
bgm.setVolume(AudioStream::External, 1.0f);
|
||||
bgm.setExtVolume1(1.0);
|
||||
meWatch.state = MeNotPlaying;
|
||||
bgm.unlockStream();
|
||||
|
||||
|
@ -213,17 +211,17 @@ struct AudioPrivate
|
|||
break;
|
||||
}
|
||||
|
||||
float vol = bgm.getVolume(AudioStream::External);
|
||||
float vol = bgm.extVolume;
|
||||
vol += fadeInStep;
|
||||
|
||||
if (vol >= 1)
|
||||
{
|
||||
/* BGM fully faded in. -> MeNotPlaying */
|
||||
vol = 1.0f;
|
||||
vol = 1.0;
|
||||
meWatch.state = MeNotPlaying;
|
||||
}
|
||||
|
||||
bgm.setVolume(AudioStream::External, vol);
|
||||
bgm.setExtVolume1(vol);
|
||||
|
||||
me.unlockStream();
|
||||
bgm.unlockStream();
|
||||
|
@ -235,10 +233,17 @@ struct AudioPrivate
|
|||
SDL_Delay(AUDIO_SLEEP);
|
||||
}
|
||||
}
|
||||
|
||||
static int meWatchFun(void *self)
|
||||
{
|
||||
static_cast<AudioPrivate*>(self)->meWatchFunInt();
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
Audio::Audio(RGSSThreadData &rtData)
|
||||
: p(new AudioPrivate(rtData))
|
||||
Audio::Audio(const Config &conf)
|
||||
: p(new AudioPrivate(conf))
|
||||
{}
|
||||
|
||||
|
||||
|
@ -312,7 +317,9 @@ void Audio::seStop()
|
|||
|
||||
void Audio::setupMidi()
|
||||
{
|
||||
shState->midiState().initIfNeeded(shState->config());
|
||||
#ifdef MIDI
|
||||
shState->midiState().initDefaultSynths();
|
||||
#endif
|
||||
}
|
||||
|
||||
float Audio::bgmPos()
|
||||
|
@ -325,12 +332,4 @@ float Audio::bgsPos()
|
|||
return p->bgs.playingOffset();
|
||||
}
|
||||
|
||||
void Audio::reset()
|
||||
{
|
||||
p->bgm.stop();
|
||||
p->bgs.stop();
|
||||
p->me.stop();
|
||||
p->se.stop();
|
||||
}
|
||||
|
||||
Audio::~Audio() { delete p; }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -33,7 +33,7 @@
|
|||
* quite make out their meaning yet) */
|
||||
|
||||
struct AudioPrivate;
|
||||
struct RGSSThreadData;
|
||||
struct Config;
|
||||
|
||||
class Audio
|
||||
{
|
||||
|
@ -67,10 +67,8 @@ public:
|
|||
float bgmPos();
|
||||
float bgsPos();
|
||||
|
||||
void reset();
|
||||
|
||||
private:
|
||||
Audio(RGSSThreadData &rtData);
|
||||
Audio(const Config &conf);
|
||||
~Audio();
|
||||
|
||||
friend struct SharedStatePrivate;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -30,21 +30,19 @@
|
|||
|
||||
AudioStream::AudioStream(ALStream::LoopMode loopMode,
|
||||
const std::string &threadId)
|
||||
: extPaused(false),
|
||||
: baseVolume(1.0),
|
||||
fadeVolume(1.0),
|
||||
extVolume(1.0),
|
||||
extPaused(false),
|
||||
noResumeStop(false),
|
||||
stream(loopMode, threadId)
|
||||
{
|
||||
current.volume = 1.0f;
|
||||
current.pitch = 1.0f;
|
||||
|
||||
for (size_t i = 0; i < VolumeTypeCount; ++i)
|
||||
volumes[i] = 1.0f;
|
||||
current.volume = 1.0;
|
||||
current.pitch = 1.0;
|
||||
|
||||
fade.active = false;
|
||||
fade.thread = 0;
|
||||
fade.threadName = std::string("audio_fadeout (") + threadId + ")";
|
||||
|
||||
fadeIn.thread = 0;
|
||||
fadeIn.threadName = std::string("audio_fadein (") + threadId + ")";
|
||||
fade.threadName = std::string("audio_fade (") + threadId + ")";
|
||||
|
||||
streamMut = SDL_CreateMutex();
|
||||
}
|
||||
|
@ -53,16 +51,10 @@ AudioStream::~AudioStream()
|
|||
{
|
||||
if (fade.thread)
|
||||
{
|
||||
fade.reqTerm.set();
|
||||
fade.reqTerm = true;
|
||||
SDL_WaitThread(fade.thread, 0);
|
||||
}
|
||||
|
||||
if (fadeIn.thread)
|
||||
{
|
||||
fadeIn.rqTerm.set();
|
||||
SDL_WaitThread(fadeIn.thread, 0);
|
||||
}
|
||||
|
||||
lockStream();
|
||||
|
||||
stream.stop();
|
||||
|
@ -78,12 +70,12 @@ void AudioStream::play(const std::string &filename,
|
|||
int pitch,
|
||||
float offset)
|
||||
{
|
||||
finiFadeOutInt();
|
||||
finiFadeInt();
|
||||
|
||||
lockStream();
|
||||
|
||||
float _volume = clamp<int>(volume, 0, 100) / 100.0f;
|
||||
float _pitch = clamp<int>(pitch, 50, 150) / 100.0f;
|
||||
float _volume = clamp<int>(volume, 0, 100) / 100.f;
|
||||
float _pitch = clamp<int>(pitch, 50, 150) / 100.f;
|
||||
|
||||
ALStream::State sState = stream.queryState();
|
||||
|
||||
|
@ -104,7 +96,7 @@ void AudioStream::play(const std::string &filename,
|
|||
&& _pitch == current.pitch
|
||||
&& (sState == ALStream::Playing || sState == ALStream::Paused))
|
||||
{
|
||||
setVolume(Base, _volume);
|
||||
setBaseVolume(_volume);
|
||||
current.volume = _volume;
|
||||
unlockStream();
|
||||
return;
|
||||
|
@ -140,15 +132,9 @@ void AudioStream::play(const std::string &filename,
|
|||
break;
|
||||
}
|
||||
|
||||
setVolume(Base, _volume);
|
||||
setBaseVolume(_volume);
|
||||
stream.setPitch(_pitch);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
setVolume(FadeIn, 0);
|
||||
startFadeIn();
|
||||
}
|
||||
|
||||
current.filename = filename;
|
||||
current.volume = _volume;
|
||||
current.pitch = _pitch;
|
||||
|
@ -163,7 +149,7 @@ void AudioStream::play(const std::string &filename,
|
|||
|
||||
void AudioStream::stop()
|
||||
{
|
||||
finiFadeOutInt();
|
||||
finiFadeInt();
|
||||
|
||||
lockStream();
|
||||
|
||||
|
@ -179,7 +165,6 @@ void AudioStream::fadeOut(int duration)
|
|||
lockStream();
|
||||
|
||||
ALStream::State sState = stream.queryState();
|
||||
noResumeStop = true;
|
||||
|
||||
if (fade.active)
|
||||
{
|
||||
|
@ -205,19 +190,18 @@ void AudioStream::fadeOut(int duration)
|
|||
|
||||
if (fade.thread)
|
||||
{
|
||||
fade.reqFini.set();
|
||||
fade.reqFini = true;
|
||||
SDL_WaitThread(fade.thread, 0);
|
||||
fade.thread = 0;
|
||||
}
|
||||
|
||||
fade.active.set();
|
||||
fade.msStep = 1.0f / duration;
|
||||
fade.reqFini.clear();
|
||||
fade.reqTerm.clear();
|
||||
fade.active = true;
|
||||
fade.msStep = (1.0) / duration;
|
||||
fade.reqFini = false;
|
||||
fade.reqTerm = false;
|
||||
fade.startTicks = SDL_GetTicks();
|
||||
|
||||
fade.thread = createSDLThread
|
||||
<AudioStream, &AudioStream::fadeOutThread>(this, fade.threadName);
|
||||
fade.thread = SDL_CreateThread(fadeThreadFun, fade.threadName.c_str(), this);
|
||||
|
||||
unlockStream();
|
||||
}
|
||||
|
@ -235,15 +219,16 @@ void AudioStream::unlockStream()
|
|||
SDL_UnlockMutex(streamMut);
|
||||
}
|
||||
|
||||
void AudioStream::setVolume(VolumeType type, float value)
|
||||
void AudioStream::setFadeVolume(float value)
|
||||
{
|
||||
volumes[type] = value;
|
||||
fadeVolume = value;
|
||||
updateVolume();
|
||||
}
|
||||
|
||||
float AudioStream::getVolume(VolumeType type)
|
||||
void AudioStream::setExtVolume1(float value)
|
||||
{
|
||||
return volumes[type];
|
||||
extVolume = value;
|
||||
updateVolume();
|
||||
}
|
||||
|
||||
float AudioStream::playingOffset()
|
||||
|
@ -251,47 +236,28 @@ float AudioStream::playingOffset()
|
|||
return stream.queryOffset();
|
||||
}
|
||||
|
||||
void AudioStream::finiFadeInt()
|
||||
{
|
||||
if (!fade.thread)
|
||||
return;
|
||||
|
||||
fade.reqFini = true;
|
||||
SDL_WaitThread(fade.thread, 0);
|
||||
fade.thread = 0;
|
||||
}
|
||||
|
||||
void AudioStream::updateVolume()
|
||||
{
|
||||
float vol = GLOBAL_VOLUME;
|
||||
|
||||
for (size_t i = 0; i < VolumeTypeCount; ++i)
|
||||
vol *= volumes[i];
|
||||
|
||||
stream.setVolume(vol);
|
||||
stream.setVolume(baseVolume * fadeVolume * extVolume);
|
||||
}
|
||||
|
||||
void AudioStream::finiFadeOutInt()
|
||||
void AudioStream::setBaseVolume(float value)
|
||||
{
|
||||
if (fade.thread)
|
||||
{
|
||||
fade.reqFini.set();
|
||||
SDL_WaitThread(fade.thread, 0);
|
||||
fade.thread = 0;
|
||||
}
|
||||
|
||||
if (fadeIn.thread)
|
||||
{
|
||||
fadeIn.rqFini.set();
|
||||
SDL_WaitThread(fadeIn.thread, 0);
|
||||
fadeIn.thread = 0;
|
||||
}
|
||||
baseVolume = value;
|
||||
updateVolume();
|
||||
}
|
||||
|
||||
void AudioStream::startFadeIn()
|
||||
{
|
||||
/* Previous fadein should always be terminated in play() */
|
||||
assert(!fadeIn.thread);
|
||||
|
||||
fadeIn.rqFini.clear();
|
||||
fadeIn.rqTerm.clear();
|
||||
fadeIn.startTicks = SDL_GetTicks();
|
||||
|
||||
fadeIn.thread = createSDLThread
|
||||
<AudioStream, &AudioStream::fadeInThread>(this, fadeIn.threadName);
|
||||
}
|
||||
|
||||
void AudioStream::fadeOutThread()
|
||||
void AudioStream::fadeThread()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
@ -302,64 +268,36 @@ void AudioStream::fadeOutThread()
|
|||
lockStream();
|
||||
|
||||
uint32_t curDur = SDL_GetTicks() - fade.startTicks;
|
||||
float resVol = 1.0f - (curDur*fade.msStep);
|
||||
float resVol = 1.0 - (curDur*fade.msStep);
|
||||
|
||||
ALStream::State state = stream.queryState();
|
||||
|
||||
if (state != ALStream::Playing
|
||||
|| resVol < 0
|
||||
|| fade.reqFini)
|
||||
|| resVol < 0
|
||||
|| fade.reqFini)
|
||||
{
|
||||
if (state != ALStream::Paused)
|
||||
stream.stop();
|
||||
|
||||
setVolume(FadeOut, 1.0f);
|
||||
setFadeVolume(1.0);
|
||||
unlockStream();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
setVolume(FadeOut, resVol);
|
||||
setFadeVolume(resVol);
|
||||
|
||||
unlockStream();
|
||||
|
||||
SDL_Delay(AUDIO_SLEEP);
|
||||
}
|
||||
|
||||
fade.active.clear();
|
||||
fade.active = false;
|
||||
}
|
||||
|
||||
void AudioStream::fadeInThread()
|
||||
int AudioStream::fadeThreadFun(void *self)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (fadeIn.rqTerm)
|
||||
break;
|
||||
static_cast<AudioStream*>(self)->fadeThread();
|
||||
|
||||
lockStream();
|
||||
|
||||
/* Fade in duration is always 1 second */
|
||||
uint32_t cur = SDL_GetTicks() - fadeIn.startTicks;
|
||||
float prog = cur / 1000.0f;
|
||||
|
||||
ALStream::State state = stream.queryState();
|
||||
|
||||
if (state != ALStream::Playing
|
||||
|| prog >= 1.0f
|
||||
|| fadeIn.rqFini)
|
||||
{
|
||||
setVolume(FadeIn, 1.0f);
|
||||
unlockStream();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* Quadratic increase (not really the same as
|
||||
* in RMVXA, but close enough) */
|
||||
setVolume(FadeIn, prog*prog);
|
||||
|
||||
unlockStream();
|
||||
|
||||
SDL_Delay(AUDIO_SLEEP);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2014 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2014 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,10 +24,12 @@
|
|||
|
||||
#include "al-util.h"
|
||||
#include "alstream.h"
|
||||
#include "sdl-util.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
struct SDL_mutex;
|
||||
struct SDL_Thread;
|
||||
|
||||
struct AudioStream
|
||||
{
|
||||
struct
|
||||
|
@ -37,28 +39,21 @@ struct AudioStream
|
|||
float pitch;
|
||||
} current;
|
||||
|
||||
/* Volumes set by external threads,
|
||||
* such as for fade-in/out.
|
||||
* Multiplied together for final
|
||||
* playback volume. Used with setVolume().
|
||||
* Base is set by play().
|
||||
* External is used by MeWatch */
|
||||
enum VolumeType
|
||||
{
|
||||
Base = 0,
|
||||
FadeOut,
|
||||
FadeIn,
|
||||
External,
|
||||
/* Volume set with 'play()' */
|
||||
float baseVolume;
|
||||
|
||||
VolumeTypeCount
|
||||
};
|
||||
/* Volume set by external threads,
|
||||
* such as for fade-in/out.
|
||||
* Multiplied with intVolume for final
|
||||
* playback volume.
|
||||
* fadeVolume: used by fade-out thread.
|
||||
* extVolume: used by MeWatch. */
|
||||
float fadeVolume;
|
||||
float extVolume;
|
||||
|
||||
/* Note that 'extPaused' and 'noResumeStop' are
|
||||
* effectively only used with the AudioStream
|
||||
* instance representing the BGM.
|
||||
* They are not AtomicFlags because they're regarded
|
||||
* as part of the underlying stream state, and
|
||||
* always accessed with the stream lock held */
|
||||
* instance representing the BGM */
|
||||
|
||||
/* Flag indicating that the MeWatch paused this
|
||||
* (BGM) stream because a ME started playing.
|
||||
|
@ -81,19 +76,18 @@ struct AudioStream
|
|||
ALStream stream;
|
||||
SDL_mutex *streamMut;
|
||||
|
||||
/* Fade out */
|
||||
struct
|
||||
{
|
||||
/* Fade out is in progress */
|
||||
AtomicFlag active;
|
||||
/* Fade is in progress */
|
||||
bool active;
|
||||
|
||||
/* Request fade thread to finish and
|
||||
* cleanup (like it normally would) */
|
||||
AtomicFlag reqFini;
|
||||
bool reqFini;
|
||||
|
||||
/* Request fade thread to terminate
|
||||
* immediately */
|
||||
AtomicFlag reqTerm;
|
||||
bool reqTerm;
|
||||
|
||||
SDL_Thread *thread;
|
||||
std::string threadName;
|
||||
|
@ -106,18 +100,6 @@ struct AudioStream
|
|||
uint32_t startTicks;
|
||||
} fade;
|
||||
|
||||
/* Fade in */
|
||||
struct
|
||||
{
|
||||
AtomicFlag rqFini;
|
||||
AtomicFlag rqTerm;
|
||||
|
||||
SDL_Thread *thread;
|
||||
std::string threadName;
|
||||
|
||||
uint32_t startTicks;
|
||||
} fadeIn;
|
||||
|
||||
AudioStream(ALStream::LoopMode loopMode,
|
||||
const std::string &threadId);
|
||||
~AudioStream();
|
||||
|
@ -135,20 +117,19 @@ struct AudioStream
|
|||
void lockStream();
|
||||
void unlockStream();
|
||||
|
||||
void setVolume(VolumeType type, float value);
|
||||
float getVolume(VolumeType type);
|
||||
void setFadeVolume(float value);
|
||||
void setExtVolume1(float value);
|
||||
|
||||
float playingOffset();
|
||||
|
||||
private:
|
||||
float volumes[VolumeTypeCount];
|
||||
void finiFadeInt();
|
||||
|
||||
void updateVolume();
|
||||
void setBaseVolume(float value);
|
||||
|
||||
void finiFadeOutInt();
|
||||
void startFadeIn();
|
||||
|
||||
void fadeOutThread();
|
||||
void fadeInThread();
|
||||
void fadeThread();
|
||||
static int fadeThreadFun(void *);
|
||||
};
|
||||
|
||||
#endif // AUDIOSTREAM_H
|
||||
|
|
|
@ -4,196 +4,196 @@ extern const StaticRect autotileRects[] =
|
|||
{
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 80.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 48.5, 80.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 48.5, 64.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 32.5, 64.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 0.5, 64.5, 15, 15 },
|
||||
{ 16.5, 64.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 16.5, 80.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 0.5, 64.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 16.5, 80.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 0.5, 64.5, 15, 15 },
|
||||
{ 16.5, 64.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 0.5, 64.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 32.5, 15, 15 },
|
||||
{ 48.5, 32.5, 15, 15 },
|
||||
{ 32.5, 48.5, 15, 15 },
|
||||
{ 48.5, 48.5, 15, 15 },
|
||||
{ 32.5, 32.5, 15, 15 },
|
||||
{ 48.5, 32.5, 15, 15 },
|
||||
{ 32.5, 48.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 32.5, 15, 15 },
|
||||
{ 48.5, 32.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 32.5, 48.5, 15, 15 },
|
||||
{ 32.5, 32.5, 15, 15 },
|
||||
{ 48.5, 32.5, 15, 15 },
|
||||
{ 48.5, 48.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 32.5, 32.5, 15, 15 },
|
||||
{ 48.5, 32.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 64.5, 15, 15 },
|
||||
{ 80.5, 64.5, 15, 15 },
|
||||
{ 64.5, 80.5, 15, 15 },
|
||||
{ 80.5, 80.5, 15, 15 },
|
||||
{ 64.5, 80.5, 15, 15 },
|
||||
{ 64.5, 64.5, 15, 15 },
|
||||
{ 80.5, 64.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 80.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 64.5, 15, 15 },
|
||||
{ 80.5, 80.5, 15, 15 },
|
||||
{ 64.5, 80.5, 15, 15 },
|
||||
{ 80.5, 80.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 64.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 80.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 32.5, 96.5, 15, 15 },
|
||||
{ 48.5, 96.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 48.5, 112.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 48.5, 96.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 48.5, 112.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 32.5, 96.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 48.5, 112.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 48.5, 112.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 0.5, 64.5, 15, 15 },
|
||||
{ 80.5, 64.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 80.5, 80.5, 15, 15 },
|
||||
{ 0.5, 80.5, 15, 15 },
|
||||
{ 32.5, 32.5, 15, 15 },
|
||||
{ 48.5, 32.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 48.5, 112.5, 15, 15 },
|
||||
{ 32.5, 112.5, 15, 15 },
|
||||
{ 0.5, 32.5, 15, 15 },
|
||||
{ 16.5, 32.5, 15, 15 },
|
||||
{ 0.5, 48.5, 15, 15 },
|
||||
{ 16.5, 48.5, 15, 15 },
|
||||
{ 0.5, 48.5, 15, 15 },
|
||||
{ 0.5, 32.5, 15, 15 },
|
||||
{ 16.5, 32.5, 15, 15 },
|
||||
{ 0.5, 48.5, 15, 15 },
|
||||
{ 80.5, 16.5, 15, 15 },
|
||||
{ 0.5, 48.5, 15, 15 },
|
||||
{ 64.5, 32.5, 15, 15 },
|
||||
{ 80.5, 32.5, 15, 15 },
|
||||
{ 80.5, 48.5, 15, 15 },
|
||||
{ 64.5, 48.5, 15, 15 },
|
||||
{ 80.5, 48.5, 15, 15 },
|
||||
{ 64.5, 32.5, 15, 15 },
|
||||
{ 80.5, 32.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 80.5, 48.5, 15, 15 },
|
||||
{ 64.5, 16.5, 15, 15 },
|
||||
{ 64.5, 96.5, 15, 15 },
|
||||
{ 80.5, 96.5, 15, 15 },
|
||||
{ 64.5, 112.5, 15, 15 },
|
||||
{ 80.5, 112.5, 15, 15 },
|
||||
{ 64.5, 112.5, 15, 15 },
|
||||
{ 64.5, 0.5, 15, 15 },
|
||||
{ 80.5, 96.5, 15, 15 },
|
||||
{ 64.5, 112.5, 15, 15 },
|
||||
{ 80.5, 112.5, 15, 15 },
|
||||
{ 64.5, 112.5, 15, 15 },
|
||||
{ 0.5, 96.5, 15, 15 },
|
||||
{ 16.5, 96.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 16.5, 112.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 0.5, 96.5, 15, 15 },
|
||||
{ 80.5, 0.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 16.5, 112.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 0.5, 32.5, 15, 15 },
|
||||
{ 80.5, 32.5, 15, 15 },
|
||||
{ 0.5, 48.5, 15, 15 },
|
||||
{ 80.5, 48.5, 15, 15 },
|
||||
{ 0.5, 48.5, 15, 15 },
|
||||
{ 0.5, 32.5, 15, 15 },
|
||||
{ 16.5, 32.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 16.5, 112.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 0.5, 96.5, 15, 15 },
|
||||
{ 80.5, 96.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 80.5, 112.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 64.5, 32.5, 15, 15 },
|
||||
{ 80.5, 32.5, 15, 15 },
|
||||
{ 64.5, 112.5, 15, 15 },
|
||||
{ 80.5, 112.5, 15, 15 },
|
||||
{ 64.5, 112.5, 15, 15 },
|
||||
{ 0.5, 32.5, 15, 15 },
|
||||
{ 80.5, 32.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 80.5, 112.5, 15, 15 },
|
||||
{ 0.5, 112.5, 15, 15 },
|
||||
{ 0.5, 0.5, 15, 15 },
|
||||
{ 16.5, 0.5, 15, 15 },
|
||||
{ 0.5, 16.5, 15, 15 },
|
||||
{ 16.5, 16.5, 15, 15 }
|
||||
{ 16.5, 16.5, 15, 15 },
|
||||
{ 0.5, 16.5, 15, 15 }
|
||||
};
|
||||
|
||||
extern const int autotileRectsN = sizeof(autotileRects) / sizeof(autotileRects[0]);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -35,10 +35,6 @@ struct ScriptBinding
|
|||
* function will perform a longjmp instead of returning,
|
||||
* so be careful about any variables with local storage */
|
||||
void (*terminate) (void);
|
||||
|
||||
/* Instructs the binding to issue a game reset.
|
||||
* Same conditions as for terminate apply */
|
||||
void (*reset) (void);
|
||||
};
|
||||
|
||||
/* VTable defined in the binding source */
|
||||
|
|
337
src/bitmap.cpp
337
src/bitmap.cpp
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -51,8 +51,6 @@
|
|||
"Operation not supported for mega surfaces"); \
|
||||
}
|
||||
|
||||
#define OUTLINE_SIZE 1
|
||||
|
||||
/* Normalize (= ensure width and
|
||||
* height are positive) */
|
||||
static IntRect normalizedRect(const IntRect &rect)
|
||||
|
@ -115,7 +113,6 @@ struct BitmapPrivate
|
|||
|
||||
~BitmapPrivate()
|
||||
{
|
||||
SDL_FreeFormat(format);
|
||||
pixman_region_fini(&tainted);
|
||||
}
|
||||
|
||||
|
@ -128,8 +125,7 @@ struct BitmapPrivate
|
|||
|
||||
void clearTaintedArea()
|
||||
{
|
||||
pixman_region_fini(&tainted);
|
||||
pixman_region_init(&tainted);
|
||||
pixman_region_clear(&tainted);
|
||||
}
|
||||
|
||||
void addTaintedArea(const IntRect &rect)
|
||||
|
@ -221,9 +217,9 @@ struct BitmapPrivate
|
|||
surf = surfConv;
|
||||
}
|
||||
|
||||
void onModified(bool freeSurface = true)
|
||||
void onModified()
|
||||
{
|
||||
if (surface && freeSurface)
|
||||
if (surface)
|
||||
{
|
||||
SDL_FreeSurface(surface);
|
||||
surface = 0;
|
||||
|
@ -233,26 +229,12 @@ struct BitmapPrivate
|
|||
}
|
||||
};
|
||||
|
||||
struct BitmapOpenHandler : FileSystem::OpenHandler
|
||||
{
|
||||
SDL_Surface *surf;
|
||||
|
||||
BitmapOpenHandler()
|
||||
: surf(0)
|
||||
{}
|
||||
|
||||
bool tryRead(SDL_RWops &ops, const char *ext)
|
||||
{
|
||||
surf = IMG_LoadTyped_RW(&ops, 1, ext);
|
||||
return surf != 0;
|
||||
}
|
||||
};
|
||||
|
||||
Bitmap::Bitmap(const char *filename)
|
||||
{
|
||||
BitmapOpenHandler handler;
|
||||
shState->fileSystem().openRead(handler, filename);
|
||||
SDL_Surface *imgSurf = handler.surf;
|
||||
SDL_RWops ops;
|
||||
const char *extension;
|
||||
shState->fileSystem().openRead(ops, filename, FileSystem::Image, false, &extension);
|
||||
SDL_Surface *imgSurf = IMG_LoadTyped_RW(&ops, 1, extension);
|
||||
|
||||
if (!imgSurf)
|
||||
throw Exception(Exception::SDLError, "Error loading image '%s': %s",
|
||||
|
@ -265,7 +247,6 @@ Bitmap::Bitmap(const char *filename)
|
|||
/* Mega surface */
|
||||
p = new BitmapPrivate(this);
|
||||
p->megaSurface = imgSurf;
|
||||
SDL_SetSurfaceBlendMode(p->megaSurface, SDL_BLENDMODE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -315,18 +296,21 @@ Bitmap::Bitmap(const Bitmap &other)
|
|||
|
||||
p->gl = shState->texPool().request(other.width(), other.height());
|
||||
|
||||
blt(0, 0, other, rect());
|
||||
blt(0, 0, &other, rect());
|
||||
}
|
||||
|
||||
Bitmap::~Bitmap()
|
||||
{
|
||||
dispose();
|
||||
if (p->megaSurface)
|
||||
SDL_FreeSurface(p->megaSurface);
|
||||
else
|
||||
shState->texPool().release(p->gl);
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
||||
int Bitmap::width() const
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
if (p->megaSurface)
|
||||
return p->megaSurface->w;
|
||||
|
||||
|
@ -335,8 +319,6 @@ int Bitmap::width() const
|
|||
|
||||
int Bitmap::height() const
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
if (p->megaSurface)
|
||||
return p->megaSurface->h;
|
||||
|
||||
|
@ -345,16 +327,14 @@ int Bitmap::height() const
|
|||
|
||||
IntRect Bitmap::rect() const
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
return IntRect(0, 0, width(), height());
|
||||
}
|
||||
|
||||
void Bitmap::blt(int x, int y,
|
||||
const Bitmap &source, IntRect rect,
|
||||
const Bitmap *source, IntRect rect,
|
||||
int opacity)
|
||||
{
|
||||
if (source.isDisposed())
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
// FIXME: RGSS allows the source rect to both lie outside
|
||||
|
@ -363,25 +343,23 @@ void Bitmap::blt(int x, int y,
|
|||
// doesn't fix anything for a direct stretch_blt call).
|
||||
|
||||
/* Clamp rect to source bitmap size */
|
||||
if (rect.x + rect.w > source.width())
|
||||
rect.w = source.width() - rect.x;
|
||||
if (rect.x + rect.w > source->width())
|
||||
rect.w = source->width() - rect.x;
|
||||
|
||||
if (rect.y + rect.h > source.height())
|
||||
rect.h = source.height() - rect.y;
|
||||
if (rect.y + rect.h > source->height())
|
||||
rect.h = source->height() - rect.y;
|
||||
|
||||
stretchBlt(IntRect(x, y, rect.w, rect.h),
|
||||
source, rect, opacity);
|
||||
}
|
||||
|
||||
void Bitmap::stretchBlt(const IntRect &destRect,
|
||||
const Bitmap &source, const IntRect &sourceRect,
|
||||
const Bitmap *source, const IntRect &sourceRect,
|
||||
int opacity)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
if (source.isDisposed())
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
opacity = clamp(opacity, 0, 255);
|
||||
|
@ -389,45 +367,13 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
|||
if (opacity == 0)
|
||||
return;
|
||||
|
||||
SDL_Surface *srcSurf = source.megaSurface();
|
||||
|
||||
if (srcSurf && shState->config().subImageFix)
|
||||
if (source->megaSurface())
|
||||
{
|
||||
/* Blit from software surface, for broken GL drivers */
|
||||
Vec2i gpTexSize;
|
||||
shState->ensureTexSize(sourceRect.w, sourceRect.h, gpTexSize);
|
||||
shState->bindTex();
|
||||
|
||||
GLMeta::subRectImageUpload(srcSurf->w, sourceRect.x, sourceRect.y, 0, 0,
|
||||
sourceRect.w, sourceRect.h, srcSurf, GL_RGBA);
|
||||
GLMeta::subRectImageEnd();
|
||||
|
||||
SimpleShader &shader = shState->shaders().simple;
|
||||
shader.bind();
|
||||
shader.setTranslation(Vec2i());
|
||||
shader.setTexSize(gpTexSize);
|
||||
|
||||
p->pushSetViewport(shader);
|
||||
p->bindFBO();
|
||||
|
||||
Quad &quad = shState->gpQuad();
|
||||
quad.setTexRect(FloatRect(0, 0, sourceRect.w, sourceRect.h));
|
||||
quad.setPosRect(destRect);
|
||||
|
||||
p->blitQuad(quad);
|
||||
p->popViewport();
|
||||
|
||||
p->addTaintedArea(destRect);
|
||||
p->onModified();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (srcSurf)
|
||||
{
|
||||
/* Blit from software surface */
|
||||
/* Don't do transparent blits for now */
|
||||
if (opacity < 255)
|
||||
source.ensureNonMega();
|
||||
source->ensureNonMega();
|
||||
|
||||
SDL_Surface *srcSurf = source->megaSurface();
|
||||
|
||||
SDL_Rect srcRect = sourceRect;
|
||||
SDL_Rect dstRect = destRect;
|
||||
|
@ -444,25 +390,26 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
|||
SDL_Surface *blitTemp =
|
||||
SDL_CreateRGBSurface(0, destRect.w, destRect.h, bpp, rMask, gMask, bMask, aMask);
|
||||
|
||||
SDL_BlitScaled(srcSurf, &srcRect, blitTemp, 0);
|
||||
// FXIME: This is supposed to be a scaled blit, put SDL2 for some reason
|
||||
// makes the source surface unusable after BlitScaled() is called. Investigate!
|
||||
SDL_BlitSurface(srcSurf, &srcRect, blitTemp, 0);
|
||||
|
||||
TEX::bind(p->gl.tex);
|
||||
|
||||
if (bltRect.w == dstRect.w && bltRect.h == dstRect.h)
|
||||
{
|
||||
/* Dest rectangle lies within bounding box */
|
||||
TEX::uploadSubImage(destRect.x, destRect.y,
|
||||
destRect.w, destRect.h,
|
||||
blitTemp->pixels, GL_RGBA);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Clipped blit */
|
||||
GLMeta::subRectImageUpload(blitTemp->w, bltRect.x - dstRect.x, bltRect.y - dstRect.y,
|
||||
bltRect.x, bltRect.y, bltRect.w, bltRect.h, blitTemp, GL_RGBA);
|
||||
GLMeta::subRectImageEnd();
|
||||
}
|
||||
|
||||
|
||||
SDL_FreeSurface(blitTemp);
|
||||
|
||||
p->onModified();
|
||||
|
@ -473,7 +420,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
|||
{
|
||||
/* Fast blit */
|
||||
GLMeta::blitBegin(p->gl);
|
||||
GLMeta::blitSource(source.p->gl);
|
||||
GLMeta::blitSource(source->p->gl);
|
||||
GLMeta::blitRectangle(sourceRect, destRect);
|
||||
GLMeta::blitEnd();
|
||||
}
|
||||
|
@ -489,10 +436,10 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
|||
GLMeta::blitRectangle(destRect, Vec2i());
|
||||
GLMeta::blitEnd();
|
||||
|
||||
FloatRect bltSubRect((float) sourceRect.x / source.width(),
|
||||
(float) sourceRect.y / source.height(),
|
||||
((float) source.width() / sourceRect.w) * ((float) destRect.w / gpTex.width),
|
||||
((float) source.height() / sourceRect.h) * ((float) destRect.h / gpTex.height));
|
||||
FloatRect bltSubRect((float) sourceRect.x / source->width(),
|
||||
(float) sourceRect.y / source->height(),
|
||||
((float) source->width() / sourceRect.w) * ((float) destRect.w / gpTex.width),
|
||||
((float) source->height() / sourceRect.h) * ((float) destRect.h / gpTex.height));
|
||||
|
||||
BltShader &shader = shState->shaders().blt;
|
||||
shader.bind();
|
||||
|
@ -504,7 +451,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
|||
quad.setTexPosRect(sourceRect, destRect);
|
||||
quad.setColor(Vec4(1, 1, 1, normOpacity));
|
||||
|
||||
source.p->bindTexture(shader);
|
||||
source->p->bindTexture(shader);
|
||||
p->bindFBO();
|
||||
p->pushSetViewport(shader);
|
||||
|
||||
|
@ -514,6 +461,7 @@ void Bitmap::stretchBlt(const IntRect &destRect,
|
|||
}
|
||||
|
||||
p->addTaintedArea(destRect);
|
||||
|
||||
p->onModified();
|
||||
}
|
||||
|
||||
|
@ -526,8 +474,6 @@ void Bitmap::fillRect(int x, int y,
|
|||
|
||||
void Bitmap::fillRect(const IntRect &rect, const Vec4 &color)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
p->fillRect(rect, color);
|
||||
|
@ -554,8 +500,6 @@ void Bitmap::gradientFillRect(const IntRect &rect,
|
|||
const Vec4 &color1, const Vec4 &color2,
|
||||
bool vertical)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
SimpleColorShader &shader = shState->shaders().simpleColor;
|
||||
|
@ -600,8 +544,6 @@ void Bitmap::clearRect(int x, int y, int width, int height)
|
|||
|
||||
void Bitmap::clearRect(const IntRect &rect)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
p->fillRect(rect, Vec4());
|
||||
|
@ -611,8 +553,6 @@ void Bitmap::clearRect(const IntRect &rect)
|
|||
|
||||
void Bitmap::blur()
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
Quad &quad = shState->gpQuad();
|
||||
|
@ -656,8 +596,6 @@ void Bitmap::blur()
|
|||
|
||||
void Bitmap::radialBlur(int angle, int divisions)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
angle = clamp<int>(angle, 0, 359);
|
||||
|
@ -751,8 +689,6 @@ void Bitmap::radialBlur(int angle, int divisions)
|
|||
|
||||
void Bitmap::clear()
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
p->bindFBO();
|
||||
|
@ -768,18 +704,8 @@ void Bitmap::clear()
|
|||
p->onModified();
|
||||
}
|
||||
|
||||
static uint32_t &getPixelAt(SDL_Surface *surf, SDL_PixelFormat *form, int x, int y)
|
||||
{
|
||||
size_t offset = x*form->BytesPerPixel + y*surf->pitch;
|
||||
uint8_t *bytes = (uint8_t*) surf->pixels + offset;
|
||||
|
||||
return *((uint32_t*) bytes);
|
||||
}
|
||||
|
||||
Color Bitmap::getPixel(int x, int y) const
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
if (x < 0 || y < 0 || x >= width() || y >= height())
|
||||
|
@ -798,7 +724,9 @@ Color Bitmap::getPixel(int x, int y) const
|
|||
glState.viewport.pop();
|
||||
}
|
||||
|
||||
uint32_t pixel = getPixelAt(p->surface, p->format, x, y);
|
||||
size_t offset = x*p->format->BytesPerPixel + y*p->surface->pitch;
|
||||
uint8_t *bytes = (uint8_t*) p->surface->pixels + offset;
|
||||
uint32_t pixel = *((uint32_t*) bytes);
|
||||
|
||||
return Color((pixel >> p->format->Rshift) & 0xFF,
|
||||
(pixel >> p->format->Gshift) & 0xFF,
|
||||
|
@ -808,8 +736,6 @@ Color Bitmap::getPixel(int x, int y) const
|
|||
|
||||
void Bitmap::setPixel(int x, int y, const Color &color)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
uint8_t pixel[] =
|
||||
|
@ -825,22 +751,11 @@ void Bitmap::setPixel(int x, int y, const Color &color)
|
|||
|
||||
p->addTaintedArea(IntRect(x, y, 1, 1));
|
||||
|
||||
/* Setting just a single pixel is no reason to throw away the
|
||||
* whole cached surface; we can just apply the same change */
|
||||
|
||||
if (p->surface)
|
||||
{
|
||||
uint32_t &surfPixel = getPixelAt(p->surface, p->format, x, y);
|
||||
surfPixel = SDL_MapRGBA(p->format, pixel[0], pixel[1], pixel[2], pixel[3]);
|
||||
}
|
||||
|
||||
p->onModified(false);
|
||||
p->onModified();
|
||||
}
|
||||
|
||||
void Bitmap::hueChange(int hue)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
if ((hue % 360) == 0)
|
||||
|
@ -854,10 +769,13 @@ void Bitmap::hueChange(int hue)
|
|||
quad.setTexPosRect(texRect, texRect);
|
||||
quad.setColor(Vec4(1, 1, 1, 1));
|
||||
|
||||
/* Calculate hue parameter */
|
||||
hue = wrapRange(hue, 0, 359);
|
||||
float hueAdj = -((M_PI * 2) / 360) * hue;
|
||||
|
||||
HueShader &shader = shState->shaders().hue;
|
||||
shader.bind();
|
||||
/* Shader expects normalized value */
|
||||
shader.setHueAdjust(wrapRange(hue, 0, 359) / 360.0f);
|
||||
shader.setHueAdjust(hueAdj);
|
||||
|
||||
FBO::bind(newTex.fbo);
|
||||
p->pushSetViewport(shader);
|
||||
|
@ -897,97 +815,8 @@ static std::string fixupString(const char *str)
|
|||
return s;
|
||||
}
|
||||
|
||||
static void applyShadow(SDL_Surface *&in, const SDL_PixelFormat &fm, const SDL_Color &c)
|
||||
{
|
||||
SDL_Surface *out = SDL_CreateRGBSurface
|
||||
(0, in->w+1, in->h+1, fm.BitsPerPixel, fm.Rmask, fm.Gmask, fm.Bmask, fm.Amask);
|
||||
|
||||
float fr = c.r / 255.0f;
|
||||
float fg = c.g / 255.0f;
|
||||
float fb = c.b / 255.0f;
|
||||
|
||||
/* We allocate an output surface one pixel wider and higher than the input,
|
||||
* (implicitly) blit a copy of the input with RGB values set to black into
|
||||
* it with x/y offset by 1, then blend the input surface over it at origin
|
||||
* (0,0) using the bitmap blit equation (see shader/bitmapBlit.frag) */
|
||||
|
||||
for (int y = 0; y < in->h+1; ++y)
|
||||
for (int x = 0; x < in->w+1; ++x)
|
||||
{
|
||||
/* src: input pixel, shd: shadow pixel */
|
||||
uint32_t src = 0, shd = 0;
|
||||
|
||||
/* Output pixel location */
|
||||
uint32_t *outP = ((uint32_t*) ((uint8_t*) out->pixels + y*out->pitch)) + x;
|
||||
|
||||
if (y < in->h && x < in->w)
|
||||
src = ((uint32_t*) ((uint8_t*) in->pixels + y*in->pitch))[x];
|
||||
|
||||
if (y > 0 && x > 0)
|
||||
shd = ((uint32_t*) ((uint8_t*) in->pixels + (y-1)*in->pitch))[x-1];
|
||||
|
||||
/* Set shadow pixel RGB values to 0 (black) */
|
||||
shd &= fm.Amask;
|
||||
|
||||
if (x == 0 || y == 0)
|
||||
{
|
||||
*outP = src;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (x == in->w || y == in->h)
|
||||
{
|
||||
*outP = shd;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Input and shadow alpha values */
|
||||
uint8_t srcA, shdA;
|
||||
srcA = (src & fm.Amask) >> fm.Ashift;
|
||||
shdA = (shd & fm.Amask) >> fm.Ashift;
|
||||
|
||||
if (srcA == 255 || shdA == 0)
|
||||
{
|
||||
*outP = src;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (srcA == 0 && shdA == 0)
|
||||
{
|
||||
*outP = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
float fSrcA = srcA / 255.0f;
|
||||
float fShdA = shdA / 255.0f;
|
||||
|
||||
/* Because opacity == 1, co1 == fSrcA */
|
||||
float co2 = fShdA * (1.0f - fSrcA);
|
||||
/* Result alpha */
|
||||
float fa = fSrcA + co2;
|
||||
/* Temp value to simplify arithmetic below */
|
||||
float co3 = fSrcA / fa;
|
||||
|
||||
/* Result colors */
|
||||
uint8_t r, g, b, a;
|
||||
|
||||
r = clamp<float>(fr * co3, 0, 1) * 255.0f;
|
||||
g = clamp<float>(fg * co3, 0, 1) * 255.0f;
|
||||
b = clamp<float>(fb * co3, 0, 1) * 255.0f;
|
||||
a = clamp<float>(fa, 0, 1) * 255.0f;
|
||||
|
||||
*outP = SDL_MapRGBA(&fm, r, g, b, a);
|
||||
}
|
||||
|
||||
/* Store new surface in the input pointer */
|
||||
SDL_FreeSurface(in);
|
||||
in = out;
|
||||
}
|
||||
|
||||
void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
std::string fixed = fixupString(str);
|
||||
|
@ -1000,13 +829,12 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
return;
|
||||
|
||||
TTF_Font *font = p->font->getSdlFont();
|
||||
const Color &fontColor = p->font->getColor();
|
||||
const Color &outColor = p->font->getOutColor();
|
||||
Color *fontColor = p->font->getColor();
|
||||
|
||||
SDL_Color c = fontColor.toSDLColor();
|
||||
c.a = 255;
|
||||
SDL_Color c;
|
||||
fontColor->toSDLColor(c);
|
||||
|
||||
float txtAlpha = fontColor.norm.w;
|
||||
float txtAlpha = fontColor->norm.w;
|
||||
|
||||
SDL_Surface *txtSurf;
|
||||
|
||||
|
@ -1017,36 +845,6 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
|
||||
p->ensureFormat(txtSurf, SDL_PIXELFORMAT_ABGR8888);
|
||||
|
||||
int rawTxtSurfH = txtSurf->h;
|
||||
|
||||
if (p->font->getShadow())
|
||||
applyShadow(txtSurf, *p->format, c);
|
||||
|
||||
/* outline using TTF_Outline and blending it together with SDL_BlitSurface
|
||||
* FIXME: outline is forced to have the same opacity as the font color */
|
||||
if (p->font->getOutline())
|
||||
{
|
||||
SDL_Color co = outColor.toSDLColor();
|
||||
co.a = 255;
|
||||
SDL_Surface *outline;
|
||||
/* set the next font render to render the outline */
|
||||
TTF_SetFontOutline(font, OUTLINE_SIZE);
|
||||
if (shState->rtData().config.solidFonts)
|
||||
outline = TTF_RenderUTF8_Solid(font, str, co);
|
||||
else
|
||||
outline = TTF_RenderUTF8_Blended(font, str, co);
|
||||
|
||||
p->ensureFormat(outline, SDL_PIXELFORMAT_ABGR8888);
|
||||
SDL_Rect outRect = {OUTLINE_SIZE, OUTLINE_SIZE, txtSurf->w, txtSurf->h};
|
||||
|
||||
SDL_SetSurfaceBlendMode(txtSurf, SDL_BLENDMODE_BLEND);
|
||||
SDL_BlitSurface(txtSurf, NULL, outline, &outRect);
|
||||
SDL_FreeSurface(txtSurf);
|
||||
txtSurf = outline;
|
||||
/* reset outline to 0 */
|
||||
TTF_SetFontOutline(font, 0);
|
||||
}
|
||||
|
||||
int alignX = rect.x;
|
||||
|
||||
switch (align)
|
||||
|
@ -1067,7 +865,7 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
if (alignX < rect.x)
|
||||
alignX = rect.x;
|
||||
|
||||
int alignY = rect.y + (rect.h - rawTxtSurfH) / 2;
|
||||
int alignY = rect.y + (rect.h - txtSurf->h) / 2;
|
||||
|
||||
float squeeze = (float) rect.w / txtSurf->w;
|
||||
|
||||
|
@ -1079,11 +877,11 @@ void Bitmap::drawText(const IntRect &rect, const char *str, int align)
|
|||
Vec2i gpTexSize;
|
||||
shState->ensureTexSize(txtSurf->w, txtSurf->h, gpTexSize);
|
||||
|
||||
bool fastBlit = !p->touchesTaintedArea(posRect) && txtAlpha == 1.0f;
|
||||
bool fastBlit = !p->touchesTaintedArea(posRect) && txtAlpha == 1.0;
|
||||
|
||||
if (fastBlit)
|
||||
{
|
||||
if (squeeze == 1.0f && !shState->config().subImageFix)
|
||||
if (squeeze == 1.0)
|
||||
{
|
||||
/* Even faster: upload directly to bitmap texture.
|
||||
* We have to make sure the posRect lies within the texture
|
||||
|
@ -1247,8 +1045,6 @@ static uint16_t utf8_to_ucs2(const char *_input,
|
|||
|
||||
IntRect Bitmap::textSize(const char *str)
|
||||
{
|
||||
guardDisposed();
|
||||
|
||||
GUARD_MEGA;
|
||||
|
||||
TTF_Font *font = p->font->getSdlFont();
|
||||
|
@ -1271,17 +1067,7 @@ IntRect Bitmap::textSize(const char *str)
|
|||
return IntRect(0, 0, w, h);
|
||||
}
|
||||
|
||||
DEF_ATTR_RD_SIMPLE(Bitmap, Font, Font&, *p->font)
|
||||
|
||||
void Bitmap::setFont(Font &value)
|
||||
{
|
||||
*p->font = value;
|
||||
}
|
||||
|
||||
void Bitmap::setInitFont(Font *value)
|
||||
{
|
||||
p->font = value;
|
||||
}
|
||||
DEF_ATTR_SIMPLE(Bitmap, Font, Font*, p->font)
|
||||
|
||||
TEXFBO &Bitmap::getGLTypes()
|
||||
{
|
||||
|
@ -1295,9 +1081,6 @@ SDL_Surface *Bitmap::megaSurface() const
|
|||
|
||||
void Bitmap::ensureNonMega() const
|
||||
{
|
||||
if (isDisposed())
|
||||
return;
|
||||
|
||||
GUARD_MEGA;
|
||||
}
|
||||
|
||||
|
@ -1310,13 +1093,3 @@ void Bitmap::taintArea(const IntRect &rect)
|
|||
{
|
||||
p->addTaintedArea(rect);
|
||||
}
|
||||
|
||||
void Bitmap::releaseResources()
|
||||
{
|
||||
if (p->megaSurface)
|
||||
SDL_FreeSurface(p->megaSurface);
|
||||
else
|
||||
shState->texPool().release(p->gl);
|
||||
|
||||
delete p;
|
||||
}
|
||||
|
|
15
src/bitmap.h
15
src/bitmap.h
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -49,11 +49,11 @@ public:
|
|||
IntRect rect() const;
|
||||
|
||||
void blt(int x, int y,
|
||||
const Bitmap &source, IntRect rect,
|
||||
const Bitmap *source, IntRect rect,
|
||||
int opacity = 255);
|
||||
|
||||
void stretchBlt(const IntRect &destRect,
|
||||
const Bitmap &source, const IntRect &sourceRect,
|
||||
const Bitmap *source, const IntRect &sourceRect,
|
||||
int opacity = 255);
|
||||
|
||||
void fillRect(int x, int y,
|
||||
|
@ -99,11 +99,7 @@ public:
|
|||
|
||||
IntRect textSize(const char *str);
|
||||
|
||||
DECL_ATTR(Font, Font&)
|
||||
|
||||
/* Sets initial reference without copying by value,
|
||||
* use at construction */
|
||||
void setInitFont(Font *value);
|
||||
DECL_ATTR(Font, Font*)
|
||||
|
||||
/* <internal> */
|
||||
TEXFBO &getGLTypes();
|
||||
|
@ -120,9 +116,6 @@ public:
|
|||
sigc::signal<void> modified;
|
||||
|
||||
private:
|
||||
void releaseResources();
|
||||
const char *klassName() const { return "bitmap"; }
|
||||
|
||||
BitmapPrivate *p;
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
p.insert(PairType(key, value));
|
||||
}
|
||||
|
||||
inline void remove(const K &key)
|
||||
inline void erase(const K &key)
|
||||
{
|
||||
p.erase(key);
|
||||
}
|
||||
|
@ -116,11 +116,6 @@ public:
|
|||
p.insert(key);
|
||||
}
|
||||
|
||||
inline void remove(const K &key)
|
||||
{
|
||||
p.erase(key);
|
||||
}
|
||||
|
||||
inline const_iterator cbegin() const
|
||||
{
|
||||
return p.cbegin();
|
||||
|
|
|
@ -1 +1 @@
|
|||
#include "liberation.ttf.xxd"
|
||||
#include "../liberation.ttf.xxd"
|
||||
|
|
241
src/config.cpp
241
src/config.cpp
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -25,15 +25,11 @@
|
|||
#include <boost/program_options/parsers.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
#include <SDL_filesystem.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "debugwriter.h"
|
||||
#include "util.h"
|
||||
#include "sdl-util.h"
|
||||
#include "iniconfig.h"
|
||||
|
||||
#ifdef INI_ENCODING
|
||||
extern "C" {
|
||||
|
@ -122,96 +118,65 @@ static bool validUtf8(const char *string)
|
|||
return true;
|
||||
}
|
||||
|
||||
static std::string prefPath(const char *org, const char *app)
|
||||
{
|
||||
char *path = SDL_GetPrefPath(org, app);
|
||||
|
||||
if (!path)
|
||||
return std::string();
|
||||
|
||||
std::string str(path);
|
||||
SDL_free(path);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::set<T> setFromVec(const std::vector<T> &vec)
|
||||
{
|
||||
return std::set<T>(vec.begin(), vec.end());
|
||||
}
|
||||
|
||||
typedef std::vector<std::string> StringVec;
|
||||
namespace po = boost::program_options;
|
||||
|
||||
#define CONF_FILE "mkxp.conf"
|
||||
|
||||
Config::Config()
|
||||
{}
|
||||
: rgssVersion(0),
|
||||
debugMode(false),
|
||||
winResizable(false),
|
||||
fullscreen(false),
|
||||
fixedAspectRatio(true),
|
||||
smoothScaling(false),
|
||||
vsync(false),
|
||||
defScreenW(0),
|
||||
defScreenH(0),
|
||||
fixedFramerate(0),
|
||||
frameSkip(true),
|
||||
solidFonts(false),
|
||||
gameFolder("."),
|
||||
anyAltToggleFS(false),
|
||||
allowSymlinks(false),
|
||||
pathCache(true),
|
||||
useScriptNames(false)
|
||||
{
|
||||
midi.chorus = false;
|
||||
midi.reverb = false;
|
||||
SE.sourceCount = 6;
|
||||
}
|
||||
|
||||
void Config::read(int argc, char *argv[])
|
||||
{
|
||||
#define PO_DESC_ALL \
|
||||
PO_DESC(rgssVersion, int, 0) \
|
||||
PO_DESC(debugMode, bool, false) \
|
||||
PO_DESC(printFPS, bool, false) \
|
||||
PO_DESC(winResizable, bool, false) \
|
||||
PO_DESC(fullscreen, bool, false) \
|
||||
PO_DESC(fixedAspectRatio, bool, true) \
|
||||
PO_DESC(smoothScaling, bool, true) \
|
||||
PO_DESC(vsync, bool, false) \
|
||||
PO_DESC(defScreenW, int, 0) \
|
||||
PO_DESC(defScreenH, int, 0) \
|
||||
PO_DESC(windowTitle, std::string, "") \
|
||||
PO_DESC(fixedFramerate, int, 0) \
|
||||
PO_DESC(frameSkip, bool, true) \
|
||||
PO_DESC(syncToRefreshrate, bool, false) \
|
||||
PO_DESC(solidFonts, bool, false) \
|
||||
PO_DESC(subImageFix, bool, false) \
|
||||
PO_DESC(enableBlitting, bool, true) \
|
||||
PO_DESC(maxTextureSize, int, 0) \
|
||||
PO_DESC(gameFolder, std::string, ".") \
|
||||
PO_DESC(anyAltToggleFS, bool, false) \
|
||||
PO_DESC(enableReset, bool, true) \
|
||||
PO_DESC(allowSymlinks, bool, false) \
|
||||
PO_DESC(dataPathOrg, std::string, "") \
|
||||
PO_DESC(dataPathApp, std::string, "") \
|
||||
PO_DESC(iconPath, std::string, "") \
|
||||
PO_DESC(execName, std::string, "Game") \
|
||||
PO_DESC(titleLanguage, std::string, "") \
|
||||
PO_DESC(midi.soundFont, std::string, "") \
|
||||
PO_DESC(midi.chorus, bool, false) \
|
||||
PO_DESC(midi.reverb, bool, false) \
|
||||
PO_DESC(SE.sourceCount, int, 6) \
|
||||
PO_DESC(customScript, std::string, "") \
|
||||
PO_DESC(pathCache, bool, true) \
|
||||
PO_DESC(useScriptNames, bool, false)
|
||||
PO_DESC(rgssVersion, int) \
|
||||
PO_DESC(debugMode, bool) \
|
||||
PO_DESC(winResizable, bool) \
|
||||
PO_DESC(fullscreen, bool) \
|
||||
PO_DESC(fixedAspectRatio, bool) \
|
||||
PO_DESC(smoothScaling, bool) \
|
||||
PO_DESC(vsync, bool) \
|
||||
PO_DESC(defScreenW, int) \
|
||||
PO_DESC(defScreenH, int) \
|
||||
PO_DESC(fixedFramerate, int) \
|
||||
PO_DESC(frameSkip, bool) \
|
||||
PO_DESC(solidFonts, bool) \
|
||||
PO_DESC(gameFolder, std::string) \
|
||||
PO_DESC(anyAltToggleFS, bool) \
|
||||
PO_DESC(allowSymlinks, bool) \
|
||||
PO_DESC(iconPath, std::string) \
|
||||
PO_DESC(titleLanguage, std::string) \
|
||||
PO_DESC(midi.soundFont, std::string) \
|
||||
PO_DESC(midi.chorus, bool) \
|
||||
PO_DESC(midi.reverb, bool) \
|
||||
PO_DESC(SE.sourceCount, int) \
|
||||
PO_DESC(customScript, std::string) \
|
||||
PO_DESC(pathCache, bool) \
|
||||
PO_DESC(useScriptNames, bool)
|
||||
|
||||
// Not gonna take your shit boost
|
||||
#define GUARD_ALL( exp ) try { exp } catch(...) {}
|
||||
|
||||
editor.debug = false;
|
||||
editor.battleTest = false;
|
||||
|
||||
/* Read arguments sent from the editor */
|
||||
if (argc > 1)
|
||||
{
|
||||
std::string argv1 = argv[1];
|
||||
/* RGSS1 uses "debug", 2 and 3 use "test" */
|
||||
if (argv1 == "debug" || argv1 == "test")
|
||||
editor.debug = true;
|
||||
else if (argv1 == "btest")
|
||||
editor.battleTest = true;
|
||||
|
||||
/* Fix offset */
|
||||
if (editor.debug || editor.battleTest)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
}
|
||||
|
||||
#define PO_DESC(key, type, def) (#key, po::value< type >()->default_value(def))
|
||||
#define PO_DESC(key, type) (#key, po::value< type >()->default_value(key))
|
||||
|
||||
po::options_description podesc;
|
||||
podesc.add_options()
|
||||
|
@ -225,39 +190,32 @@ void Config::read(int argc, char *argv[])
|
|||
po::variables_map vm;
|
||||
|
||||
/* Parse command line options */
|
||||
try
|
||||
{
|
||||
po::parsed_options cmdPo =
|
||||
po::command_line_parser(argc, argv).options(podesc).run();
|
||||
po::store(cmdPo, vm);
|
||||
}
|
||||
catch (po::error &error)
|
||||
{
|
||||
Debug() << "Command line:" << error.what();
|
||||
}
|
||||
po::parsed_options cmdPo =
|
||||
po::command_line_parser(argc, argv).options(podesc)
|
||||
.allow_unregistered()
|
||||
.run();
|
||||
|
||||
/* Parse configuration file */
|
||||
SDLRWStream confFile(CONF_FILE, "r");
|
||||
GUARD_ALL( po::store(cmdPo, vm); )
|
||||
|
||||
/* Parse configuration file (mkxp.conf) */
|
||||
std::ifstream confFile;
|
||||
confFile.open("mkxp.conf");
|
||||
|
||||
if (confFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
po::store(po::parse_config_file(confFile.stream(), podesc, true), vm);
|
||||
po::notify(vm);
|
||||
}
|
||||
catch (po::error &error)
|
||||
{
|
||||
Debug() << CONF_FILE":" << error.what();
|
||||
}
|
||||
GUARD_ALL( po::store(po::parse_config_file(confFile, podesc, true), vm); )
|
||||
}
|
||||
|
||||
confFile.close();
|
||||
|
||||
po::notify(vm);
|
||||
|
||||
#undef PO_DESC
|
||||
#define PO_DESC(key, type, def) GUARD_ALL( key = vm[#key].as< type >(); )
|
||||
#define PO_DESC(key, type) GUARD_ALL( key = vm[#key].as< type >(); )
|
||||
|
||||
PO_DESC_ALL;
|
||||
|
||||
GUARD_ALL( preloadScripts = setFromVec(vm["preloadScript"].as<StringVec>()); );
|
||||
GUARD_ALL( preloadScripts = vm["preloadScript"].as<StringVec>(); );
|
||||
|
||||
GUARD_ALL( rtps = vm["RTP"].as<StringVec>(); );
|
||||
|
||||
|
@ -271,11 +229,6 @@ void Config::read(int argc, char *argv[])
|
|||
rgssVersion = clamp(rgssVersion, 0, 3);
|
||||
|
||||
SE.sourceCount = clamp(SE.sourceCount, 1, 64);
|
||||
|
||||
if (!dataPathOrg.empty() && !dataPathApp.empty())
|
||||
customDataPath = prefPath(dataPathOrg.c_str(), dataPathApp.c_str());
|
||||
|
||||
commonDataPath = prefPath(".", "mkxp");
|
||||
}
|
||||
|
||||
static std::string baseName(const std::string &path)
|
||||
|
@ -288,61 +241,35 @@ static std::string baseName(const std::string &path)
|
|||
return path.substr(pos + 1);
|
||||
}
|
||||
|
||||
static void setupScreenSize(Config &conf)
|
||||
{
|
||||
if (conf.defScreenW <= 0)
|
||||
conf.defScreenW = (conf.rgssVersion == 1 ? 640 : 544);
|
||||
|
||||
if (conf.defScreenH <= 0)
|
||||
conf.defScreenH = (conf.rgssVersion == 1 ? 480 : 416);
|
||||
}
|
||||
|
||||
void Config::readGameINI()
|
||||
{
|
||||
if (!customScript.empty())
|
||||
{
|
||||
game.title = baseName(customScript);
|
||||
|
||||
if (rgssVersion == 0)
|
||||
rgssVersion = 1;
|
||||
|
||||
setupScreenSize(*this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::string iniFilename = execName + ".ini";
|
||||
SDLRWStream iniFile(iniFilename.c_str(), "r");
|
||||
po::options_description podesc;
|
||||
podesc.add_options()
|
||||
("Game.Title", po::value<std::string>())
|
||||
("Game.Scripts", po::value<std::string>())
|
||||
;
|
||||
|
||||
if (iniFile)
|
||||
{
|
||||
INIConfiguration ic;
|
||||
if(ic.load(iniFile.stream()))
|
||||
{
|
||||
GUARD_ALL( game.title = ic.getStringProperty("Game", "Title"); );
|
||||
GUARD_ALL( game.scripts = ic.getStringProperty("Game", "Scripts"); );
|
||||
std::string iniPath = gameFolder + "/Game.ini";
|
||||
|
||||
strReplace(game.scripts, '\\', '/');
|
||||
std::ifstream iniFile;
|
||||
iniFile.open((iniPath).c_str());
|
||||
|
||||
if (game.title.empty())
|
||||
{
|
||||
Debug() << iniFilename + ": Could not find Game.Title property";
|
||||
}
|
||||
po::variables_map vm;
|
||||
GUARD_ALL( po::store(po::parse_config_file(iniFile, podesc, true), vm); )
|
||||
po::notify(vm);
|
||||
|
||||
if (game.scripts.empty())
|
||||
{
|
||||
Debug() << iniFilename + ": Could not find Game.Scripts property";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug() << iniFilename + ": Failed to parse ini file";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug() << "FAILED to open" << iniFilename;
|
||||
}
|
||||
iniFile.close();
|
||||
|
||||
GUARD_ALL( game.title = vm["Game.Title"].as<std::string>(); );
|
||||
GUARD_ALL( game.scripts = vm["Game.Scripts"].as<std::string>(); );
|
||||
|
||||
strReplace(game.scripts, '\\', '/');
|
||||
|
||||
#ifdef INI_ENCODING
|
||||
/* Can add more later */
|
||||
|
@ -428,5 +355,9 @@ void Config::readGameINI()
|
|||
}
|
||||
}
|
||||
|
||||
setupScreenSize(*this);
|
||||
if (defScreenW <= 0)
|
||||
defScreenW = (rgssVersion == 1 ? 640 : 544);
|
||||
|
||||
if (defScreenH <= 0)
|
||||
defScreenH = (rgssVersion == 1 ? 480 : 416);
|
||||
}
|
||||
|
|
27
src/config.h
27
src/config.h
|
@ -3,7 +3,7 @@
|
|||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -24,14 +24,12 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
struct Config
|
||||
{
|
||||
int rgssVersion;
|
||||
|
||||
bool debugMode;
|
||||
bool printFPS;
|
||||
|
||||
bool winResizable;
|
||||
bool fullscreen;
|
||||
|
@ -41,29 +39,18 @@ struct Config
|
|||
|
||||
int defScreenW;
|
||||
int defScreenH;
|
||||
std::string windowTitle;
|
||||
|
||||
int fixedFramerate;
|
||||
bool frameSkip;
|
||||
bool syncToRefreshrate;
|
||||
|
||||
bool solidFonts;
|
||||
|
||||
bool subImageFix;
|
||||
bool enableBlitting;
|
||||
int maxTextureSize;
|
||||
|
||||
std::string gameFolder;
|
||||
bool anyAltToggleFS;
|
||||
bool enableReset;
|
||||
bool allowSymlinks;
|
||||
bool pathCache;
|
||||
|
||||
std::string dataPathOrg;
|
||||
std::string dataPathApp;
|
||||
|
||||
std::string iconPath;
|
||||
std::string execName;
|
||||
std::string titleLanguage;
|
||||
|
||||
struct
|
||||
|
@ -81,29 +68,19 @@ struct Config
|
|||
bool useScriptNames;
|
||||
|
||||
std::string customScript;
|
||||
std::set<std::string> preloadScripts;
|
||||
std::vector<std::string> preloadScripts;
|
||||
std::vector<std::string> rtps;
|
||||
|
||||
std::vector<std::string> fontSubs;
|
||||
|
||||
std::vector<std::string> rubyLoadpaths;
|
||||
|
||||
/* Editor flags */
|
||||
struct {
|
||||
bool debug;
|
||||
bool battleTest;
|
||||
} editor;
|
||||
|
||||
/* Game INI contents */
|
||||
struct {
|
||||
std::string scripts;
|
||||
std::string title;
|
||||
} game;
|
||||
|
||||
/* Internal */
|
||||
std::string customDataPath;
|
||||
std::string commonDataPath;
|
||||
|
||||
Config();
|
||||
|
||||
void read(int argc, char *argv[]);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
** gl-debug.cpp
|
||||
** debuglogger.cpp
|
||||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -19,25 +19,25 @@
|
|||
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "gl-debug.h"
|
||||
#include "debuglogger.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "gl-fun.h"
|
||||
|
||||
struct GLDebugLoggerPrivate
|
||||
struct DebugLoggerPrivate
|
||||
{
|
||||
std::ostream *stream;
|
||||
|
||||
GLDebugLoggerPrivate(const char *logFilename)
|
||||
DebugLoggerPrivate(const char *logFilename)
|
||||
{
|
||||
(void) logFilename;
|
||||
|
||||
stream = &std::clog;
|
||||
}
|
||||
|
||||
~GLDebugLoggerPrivate()
|
||||
~DebugLoggerPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ static void APIENTRY arbDebugFunc(GLenum source,
|
|||
const GLchar* message,
|
||||
const void* userParam)
|
||||
{
|
||||
GLDebugLoggerPrivate *p =
|
||||
static_cast<GLDebugLoggerPrivate*>(const_cast<void*>(userParam));
|
||||
DebugLoggerPrivate *p =
|
||||
static_cast<DebugLoggerPrivate*>(const_cast<void*>(userParam));
|
||||
|
||||
(void) source;
|
||||
(void) type;
|
||||
|
@ -75,9 +75,9 @@ static void APIENTRY arbDebugFunc(GLenum source,
|
|||
p->writeLine(message);
|
||||
}
|
||||
|
||||
GLDebugLogger::GLDebugLogger(const char *filename)
|
||||
DebugLogger::DebugLogger(const char *filename)
|
||||
{
|
||||
p = new GLDebugLoggerPrivate(filename);
|
||||
p = new DebugLoggerPrivate(filename);
|
||||
|
||||
if (gl.DebugMessageCallback)
|
||||
gl.DebugMessageCallback(arbDebugFunc, p);
|
||||
|
@ -85,7 +85,7 @@ GLDebugLogger::GLDebugLogger(const char *filename)
|
|||
Debug() << "DebugLogger: no debug extensions found";
|
||||
}
|
||||
|
||||
GLDebugLogger::~GLDebugLogger()
|
||||
DebugLogger::~DebugLogger()
|
||||
{
|
||||
delete p;
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
** gl-debug.h
|
||||
** debuglogger.h
|
||||
**
|
||||
** This file is part of mkxp.
|
||||
**
|
||||
** Copyright (C) 2013 - 2021 Amaryllis Kulla <ancurio@mapleshrine.eu>
|
||||
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
||||
**
|
||||
** mkxp is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,30 +22,16 @@
|
|||
#ifndef DEBUGLOGGER_H
|
||||
#define DEBUGLOGGER_H
|
||||
|
||||
#include "gl-fun.h"
|
||||
struct DebugLoggerPrivate;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
|
||||
struct GLDebugLoggerPrivate;
|
||||
|
||||
class GLDebugLogger
|
||||
class DebugLogger
|
||||
{
|
||||
public:
|
||||
GLDebugLogger(const char *filename = 0);
|
||||
~GLDebugLogger();
|
||||
DebugLogger(const char *filename = 0);
|
||||
~DebugLogger();
|
||||
|
||||
private:
|
||||
GLDebugLoggerPrivate *p;
|
||||
DebugLoggerPrivate *p;
|
||||
};
|
||||
|
||||
#define GL_MARKER(format, ...) \
|
||||
if (gl.StringMarker) \
|
||||
{ \
|
||||
char buf[128]; \
|
||||
int len = snprintf(buf, sizeof(buf), format, ##__VA_ARGS__); \
|
||||
gl.StringMarker(std::min<size_t>(len, sizeof(buf)), buf); \
|
||||
}
|
||||
|
||||
|
||||
#endif // DEBUGLOGGER_H
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue