Compare commits

..

1 Commits

Author SHA1 Message Date
Mook 8d5c841648 Make it easier to change the bundled font.
This makes it easier to play CJK games, since the embedded font must have
the glyphs necessary to display the game text.

The qmake portion is untested, but should hopefully not break the build.

See also #135
2015-10-25 21:27:20 -07:00
162 changed files with 499 additions and 982 deletions

View File

@ -1,5 +0,0 @@
root=true
[*]
end_of_line = lf
indent_style = tab
indent_size = 4

View File

@ -8,6 +8,8 @@ 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)")
set(EXTERNAL_LIB_PATH "" CACHE PATH "External precompiled lib prefix")
set(BUNDLED_FONT "liberation" CACHE STRING "Bundled font name; file must exist in assets")
set_property(CACHE BUNDLED_FONT PROPERTY ADVANCED ON)
## Misc setup ##
@ -110,7 +112,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
@ -168,7 +169,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
@ -207,11 +207,6 @@ set(MAIN_SOURCE
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 ##
@ -241,7 +236,7 @@ set(EMBEDDED_INPUT
shader/blurH.vert
shader/blurV.vert
shader/simpleMatrix.vert
assets/liberation.ttf
assets/${BUNDLED_FONT}.ttf
assets/icon.png
)
@ -409,15 +404,14 @@ add_executable(${PROJECT_NAME} MACOSX_BUNDLE
target_compile_definitions(${PROJECT_NAME} PRIVATE
${DEFINES}
BUNDLED_FONT=${BUNDLED_FONT}
)
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}

View File

@ -1,19 +1,13 @@
# 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.
It is licensed under the GNU General Public License v2+.
## Prebuilt binaries
[**Linux / Windows**](https://www.mapleshrine.eu/releases/)
[**Linux (32bit/64bit)**](http://ancurio.bplaced.net/mkxp/generic/)
[**OSX**](https://app.box.com/mkxpmacbuilds) by Ali
## 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.
[**Windows (mingw-w64 32bit)**](http://ancurio.bplaced.net/mkxp/mingw32/)
## Bindings
Bindings provide the glue code for an interpreted language environment to run game scripts in. Currently there are three bindings:
@ -89,7 +83,7 @@ To run mkxp, you should have a graphics card capable of at least **OpenGL (ES) 2
## 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.
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://www.dropbox.com/s/mtp44ur367m2zts/mkxp-depkit.tar.xz). Read the "README" for instructions.
## Configuration
@ -105,7 +99,7 @@ Example: `./mkxp --gameFolder="my game" --vsync=true --fixedFramerate=60`
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)
You can use this public domain soundfont: [GMGSx.sf2](https://www.dropbox.com/s/qxdvoxxcexsvn43/GMGSx.sf2?dl=0)
## Fonts

View File

@ -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,15 +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;
@ -144,8 +135,6 @@ audioBindingInit()
{
BIND_POS( bgm );
BIND_POS( bgs );
_rb_define_module_function(module, "setup_midi", audioSetupMidi);
}
BIND_PLAY_STOP( se )

View File

@ -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
@ -80,7 +80,6 @@ RB_METHOD(mriP);
RB_METHOD(mkxpDataDirectory);
RB_METHOD(mkxpPuts);
RB_METHOD(mkxpRawKeyStates);
RB_METHOD(mkxpMouseInWindow);
RB_METHOD(mriRgssMain);
RB_METHOD(mriRgssStop);
@ -145,18 +144,8 @@ static void mriBindingInit()
_rb_define_module_function(mod, "data_directory", mkxpDataDirectory);
_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
@ -233,13 +222,6 @@ RB_METHOD(mkxpRawKeyStates)
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);
@ -470,9 +452,8 @@ 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)

View File

@ -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

View File

@ -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

View File

@ -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
@ -67,7 +67,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 +90,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>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,30 +48,12 @@ 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);
@ -106,6 +65,13 @@ RB_METHOD(fontInitialize)
if (rgssVer >= 3)
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;
}
@ -139,17 +105,57 @@ 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, "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];
}
@ -217,15 +223,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];
}
@ -265,24 +267,7 @@ fontBindingInit()
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);
rb_iv_set(klass, "default_name", rb_str_new_cstr(Font::getDefaultName()));
if (rgssVer >= 3)
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color", ColorType);
@ -325,4 +310,14 @@ fontBindingInit()
INIT_PROP_BIND(Font, Outline, "outline");
INIT_PROP_BIND(Font, OutColor, "out_color");
}
if (rgssVer >= 2)
{
VALUE defNames = rb_ary_new2(3);
rb_ary_push(defNames, rb_str_new2("Verdana"));
rb_ary_push(defNames, rb_str_new2("Arial"));
rb_ary_push(defNames, rb_str_new2("Courier New"));
FontSetDefaultName(1, &defNames, klass);
}
}

View File

@ -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
@ -183,18 +183,6 @@ RB_METHOD(graphicsReset)
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)
@ -235,11 +223,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" );
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -114,17 +114,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);
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -86,12 +86,6 @@
# defScreenH=480
# Override the game window title
# (default: none)
#
# windowTitle=Custom Title
# Enforce a static frame rate
# (0 = disabled)
#
@ -130,26 +124,6 @@
# 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)
#

View File

@ -8,10 +8,6 @@ INCLUDEPATH += . src
CONFIG(release, debug|release): DEFINES += NDEBUG
CONFIG += c++11
# And for older qmake versions..
QMAKE_CXXFLAGS += -std=c++11
isEmpty(BINDING) {
BINDING = MRI
}
@ -93,7 +89,6 @@ HEADERS += \
src/flashable.h \
src/font.h \
src/input.h \
src/iniconfig.h \
src/plane.h \
src/scene.h \
src/sprite.h \
@ -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 \
@ -228,6 +222,8 @@ defineReplace(xxdOutput) {
return($$basename(1).xxd)
}
DEFINES += BUNDLED_FONT=liberation
# xxd
xxd.output_function = xxdOutput
xxd.commands = xxd -i ${QMAKE_FILE_NAME} > ${QMAKE_FILE_OUT}

View File

@ -1,40 +1,48 @@
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);
gl_FragColor = color;
/* 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;
/* Remember old I and color */
float IOriginal = I;
vec4 coOriginal = color;
/* 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 = (IOriginal == 0.0) ? coOriginal : color;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -221,9 +221,9 @@ struct BitmapPrivate
surf = surfConv;
}
void onModified(bool freeSurface = true)
void onModified()
{
if (surface && freeSurface)
if (surface)
{
SDL_FreeSurface(surface);
surface = 0;
@ -768,14 +768,6 @@ 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();
@ -798,7 +790,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,
@ -825,16 +819,7 @@ 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)
@ -854,10 +839,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);

View File

@ -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

View File

@ -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

View File

@ -1 +1,4 @@
#include "liberation.ttf.xxd"
#define BUNDLED_FONT_NAME BUNDLED_FONT.ttf.xxd
#define STRINGIFY(x) #x
#define INCLUDE_FILE(x) STRINGIFY(x)
#include INCLUDE_FILE(BUNDLED_FONT_NAME)

View File

@ -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,6 @@
#include "debugwriter.h"
#include "util.h"
#include "sdl-util.h"
#include "iniconfig.h"
#ifdef INI_ENCODING
extern "C" {
@ -135,12 +134,6 @@ static std::string prefPath(const char *org, const char *app)
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;
@ -162,14 +155,11 @@ void Config::read(int argc, char *argv[])
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) \
@ -190,27 +180,6 @@ void Config::read(int argc, char *argv[])
// 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))
po::options_description podesc;
@ -257,7 +226,7 @@ void Config::read(int argc, char *argv[])
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>(); );
@ -311,32 +280,26 @@ void Config::readGameINI()
return;
}
po::options_description podesc;
podesc.add_options()
("Game.Title", po::value<std::string>())
("Game.Scripts", po::value<std::string>())
;
po::variables_map vm;
std::string iniFilename = execName + ".ini";
SDLRWStream iniFile(iniFilename.c_str(), "r");
if (iniFile)
{
INIConfiguration ic;
if(ic.load(iniFile.stream()))
try
{
GUARD_ALL( game.title = ic.getStringProperty("Game", "Title"); );
GUARD_ALL( game.scripts = ic.getStringProperty("Game", "Scripts"); );
strReplace(game.scripts, '\\', '/');
if (game.title.empty())
{
Debug() << iniFilename + ": Could not find Game.Title property";
}
if (game.scripts.empty())
{
Debug() << iniFilename + ": Could not find Game.Scripts property";
}
po::store(po::parse_config_file(iniFile.stream(), podesc, true), vm);
po::notify(vm);
}
else
catch (po::error &error)
{
Debug() << iniFilename + ": Failed to parse ini file";
Debug() << iniFilename + ":" << error.what();
}
}
else
@ -344,6 +307,11 @@ void Config::readGameINI()
Debug() << "FAILED to open" << iniFilename;
}
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 */
const char *languages[] =

View File

@ -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,7 +24,6 @@
#include <string>
#include <vector>
#include <set>
struct Config
{
@ -41,7 +40,6 @@ struct Config
int defScreenW;
int defScreenH;
std::string windowTitle;
int fixedFramerate;
bool frameSkip;
@ -50,8 +48,6 @@ struct Config
bool solidFonts;
bool subImageFix;
bool enableBlitting;
int maxTextureSize;
std::string gameFolder;
bool anyAltToggleFS;
@ -81,19 +77,13 @@ 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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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,9 +27,9 @@
#include <SDL_timer.h>
#include <SDL_thread.h>
#include <SDL_touch.h>
#include <SDL_rect.h>
#include <al.h>
#include <alc.h>
#include <alext.h>
#include "sharedstate.h"
@ -83,7 +83,6 @@ enum
REQUEST_SETCURSORVISIBLE,
UPDATE_FPS,
UPDATE_SCREEN_RECT,
EVENT_COUNT
};
@ -112,11 +111,7 @@ void EventThread::process(RGSSThreadData &rtData)
UnidirMessage<Vec2i> &windowSizeMsg = rtData.windowSizeMsg;
initALCFunctions(rtData.alcDev);
// XXX this function breaks input focus on OSX
#ifndef __MACOSX__
SDL_SetEventFilter(eventFilter, &rtData);
#endif
fullscreen = rtData.config.fullscreen;
int toggleFSMod = rtData.config.anyAltToggleFS ? KMOD_ALT : KMOD_LALT;
@ -132,11 +127,7 @@ void EventThread::process(RGSSThreadData &rtData)
bool displayingFPS = false;
bool cursorInWindow = false;
/* Will be updated eventually */
SDL_Rect gameScreen = { 0, 0, 0, 0 };
/* SDL doesn't send an initial FOCUS_GAINED event */
bool windowFocused = true;
bool windowFocused = false;
bool terminate = false;
@ -173,7 +164,7 @@ void EventThread::process(RGSSThreadData &rtData)
delete sMenu;
sMenu = 0;
updateCursorState(cursorInWindow && windowFocused, gameScreen);
updateCursorState(cursorInWindow && windowFocused);
}
continue;
@ -214,14 +205,14 @@ void EventThread::process(RGSSThreadData &rtData)
case SDL_WINDOWEVENT_ENTER :
cursorInWindow = true;
mouseState.inWindow = true;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused && !sMenu);
break;
case SDL_WINDOWEVENT_LEAVE :
cursorInWindow = false;
mouseState.inWindow = false;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused && !sMenu);
break;
@ -232,13 +223,13 @@ void EventThread::process(RGSSThreadData &rtData)
case SDL_WINDOWEVENT_FOCUS_GAINED :
windowFocused = true;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused && !sMenu);
break;
case SDL_WINDOWEVENT_FOCUS_LOST :
windowFocused = false;
updateCursorState(cursorInWindow && windowFocused && !sMenu, gameScreen);
updateCursorState(cursorInWindow && windowFocused && !sMenu);
resetInputStates();
break;
@ -271,7 +262,7 @@ void EventThread::process(RGSSThreadData &rtData)
if (!sMenu)
{
sMenu = new SettingsMenu(rtData);
updateCursorState(false, gameScreen);
updateCursorState(false);
}
sMenu->raise();
@ -295,14 +286,14 @@ void EventThread::process(RGSSThreadData &rtData)
if (fullscreen)
{
/* Prevent fullscreen flicker */
strncpy(pendingTitle, rtData.config.windowTitle.c_str(),
strncpy(pendingTitle, rtData.config.game.title.c_str(),
sizeof(pendingTitle));
havePendingTitle = true;
break;
}
SDL_SetWindowTitle(win, rtData.config.windowTitle.c_str());
SDL_SetWindowTitle(win, rtData.config.game.title.c_str());
}
break;
@ -377,7 +368,6 @@ void EventThread::process(RGSSThreadData &rtData)
case SDL_MOUSEMOTION :
mouseState.x = event.motion.x;
mouseState.y = event.motion.y;
updateCursorState(cursorInWindow, gameScreen);
break;
case SDL_FINGERDOWN :
@ -409,7 +399,7 @@ void EventThread::process(RGSSThreadData &rtData)
case REQUEST_MESSAGEBOX :
SDL_ShowSimpleMessageBox(event.user.code,
rtData.config.windowTitle.c_str(),
rtData.config.game.title.c_str(),
(const char*) event.user.data1, win);
free(event.user.data1);
msgBoxDone.set();
@ -417,7 +407,7 @@ void EventThread::process(RGSSThreadData &rtData)
case REQUEST_SETCURSORVISIBLE :
showCursor = event.user.code;
updateCursorState(cursorInWindow, gameScreen);
updateCursorState(cursorInWindow);
break;
case UPDATE_FPS :
@ -428,7 +418,7 @@ void EventThread::process(RGSSThreadData &rtData)
break;
snprintf(buffer, sizeof(buffer), "%s - %d FPS",
rtData.config.windowTitle.c_str(), event.user.code);
rtData.config.game.title.c_str(), event.user.code);
/* Updating the window title in fullscreen
* mode seems to cause flickering */
@ -442,15 +432,6 @@ void EventThread::process(RGSSThreadData &rtData)
SDL_SetWindowTitle(win, buffer);
break;
case UPDATE_SCREEN_RECT :
gameScreen.x = event.user.windowID;
gameScreen.y = event.user.code;
gameScreen.w = reinterpret_cast<intptr_t>(event.user.data1);
gameScreen.h = reinterpret_cast<intptr_t>(event.user.data2);
updateCursorState(cursorInWindow, gameScreen);
break;
}
}
@ -545,13 +526,9 @@ void EventThread::setFullscreen(SDL_Window *win, bool mode)
fullscreen = mode;
}
void EventThread::updateCursorState(bool inWindow,
const SDL_Rect &screen)
void EventThread::updateCursorState(bool inWindow)
{
SDL_Point pos = { mouseState.x, mouseState.y };
bool inScreen = inWindow && SDL_PointInRect(&pos, &screen);
if (inScreen)
if (inWindow)
SDL_ShowCursor(showCursor ? SDL_TRUE : SDL_FALSE);
else
SDL_ShowCursor(SDL_TRUE);
@ -657,19 +634,6 @@ void EventThread::notifyFrame()
SDL_PushEvent(&event);
}
void EventThread::notifyGameScreenChange(const SDL_Rect &screen)
{
/* We have to get a bit hacky here to fit the rectangle
* data into the user event struct */
SDL_Event event;
event.type = usrIdStart + UPDATE_SCREEN_RECT;
event.user.windowID = screen.x;
event.user.code = screen.y;
event.user.data1 = reinterpret_cast<void*>(screen.w);
event.user.data2 = reinterpret_cast<void*>(screen.h);
SDL_PushEvent(&event);
}
void SyncPoint::haltThreads()
{
if (mainSync.locked)

View File

@ -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
@ -36,9 +36,8 @@
#include <stdint.h>
#include <alc.h>
struct RGSSThreadData;
typedef struct ALCdevice_struct ALCdevice;
struct SDL_Window;
union SDL_Event;
@ -99,16 +98,12 @@ public:
/* RGSS thread calls this once per frame */
void notifyFrame();
/* Called on game screen (size / offset) changes */
void notifyGameScreenChange(const SDL_Rect &screen);
private:
static int eventFilter(void *, SDL_Event*);
void resetInputStates();
void setFullscreen(SDL_Window *, bool mode);
void updateCursorState(bool inWindow,
const SDL_Rect &screen);
void updateCursorState(bool inWindow);
bool fullscreen;
bool showCursor;

View File

@ -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

View File

@ -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
@ -311,32 +311,18 @@ struct FileSystemPrivate
bool havePathCache;
};
static void throwPhysfsError(const char *desc)
{
PHYSFS_ErrorCode ec = PHYSFS_getLastErrorCode();
const char *englishStr = PHYSFS_getErrorByCode(ec);
throw Exception(Exception::PHYSFSError, "%s: %s", desc, englishStr);
}
FileSystem::FileSystem(const char *argv0,
bool allowSymlinks)
{
if (PHYSFS_init(argv0) == 0)
throwPhysfsError("Error initializing PhysFS");
/* One error (=return 0) turns the whole product to 0 */
int er = 1;
er *= PHYSFS_registerArchiver(&RGSS1_Archiver);
er *= PHYSFS_registerArchiver(&RGSS2_Archiver);
er *= PHYSFS_registerArchiver(&RGSS3_Archiver);
if (er == 0)
throwPhysfsError("Error registering PhysFS RGSS archiver");
p = new FileSystemPrivate;
p->havePathCache = false;
PHYSFS_init(argv0);
PHYSFS_registerArchiver(&RGSS1_Archiver);
PHYSFS_registerArchiver(&RGSS2_Archiver);
PHYSFS_registerArchiver(&RGSS3_Archiver);
if (allowSymlinks)
PHYSFS_permitSymbolicLinks(1);
}
@ -412,8 +398,8 @@ struct CacheEnumData
}
};
static PHYSFS_EnumerateCallbackResult
cacheEnumCB(void *d, const char *origdir, const char *fname)
static void cacheEnumCB(void *d, const char *origdir,
const char *fname)
{
CacheEnumData &data = *static_cast<CacheEnumData*>(d);
char fullPath[512];
@ -440,7 +426,7 @@ cacheEnumCB(void *d, const char *origdir, const char *fname)
/* Iterate over its contents */
data.fileLists.push(&list);
PHYSFS_enumerate(fullPath, cacheEnumCB, d);
PHYSFS_enumerateFilesCallback(fullPath, cacheEnumCB, d);
data.fileLists.pop();
}
else
@ -455,15 +441,13 @@ cacheEnumCB(void *d, const char *origdir, const char *fname)
/* Add the lower -> mixed mapping of the file's full path */
data.p->pathCache.insert(lowerCase, mixedCase);
}
return PHYSFS_ENUM_OK;
}
void FileSystem::createPathCache()
{
CacheEnumData data(p);
data.fileLists.push(&p->fileLists[""]);
PHYSFS_enumerate("", cacheEnumCB, &data);
PHYSFS_enumerateFilesCallback("", cacheEnumCB, &data);
p->havePathCache = true;
}
@ -474,8 +458,8 @@ struct FontSetsCBData
SharedFontState *sfs;
};
static PHYSFS_EnumerateCallbackResult
fontSetEnumCB (void *data, const char *dir, const char *fname)
static void fontSetEnumCB(void *data, const char *,
const char *fname)
{
FontSetsCBData *d = static_cast<FontSetsCBData*>(data);
@ -483,7 +467,7 @@ fontSetEnumCB (void *data, const char *dir, const char *fname)
const char *ext = findExt(fname);
if (!ext)
return PHYSFS_ENUM_OK;
return;
char lowExt[8];
size_t i;
@ -493,15 +477,15 @@ fontSetEnumCB (void *data, const char *dir, const char *fname)
lowExt[i] = '\0';
if (strcmp(lowExt, "ttf") && strcmp(lowExt, "otf"))
return PHYSFS_ENUM_OK;
return;
char filename[512];
snprintf(filename, sizeof(filename), "%s/%s", dir, fname);
snprintf(filename, sizeof(filename), "Fonts/%s", fname);
PHYSFS_File *handle = PHYSFS_openRead(filename);
if (!handle)
return PHYSFS_ENUM_ERROR;
return;
SDL_RWops ops;
initReadOps(handle, ops, false);
@ -509,35 +493,13 @@ fontSetEnumCB (void *data, const char *dir, const char *fname)
d->sfs->initFontSetCB(ops, filename);
SDL_RWclose(&ops);
return PHYSFS_ENUM_OK;
}
/* Basically just a case-insensitive search
* for the folder "Fonts"... */
static PHYSFS_EnumerateCallbackResult
findFontsFolderCB(void *data, const char *, const char *fname)
{
size_t i = 0;
char buffer[512];
const char *s = fname;
while (*s && i < sizeof(buffer))
buffer[i++] = tolower(*s++);
buffer[i] = '\0';
if (strcmp(buffer, "fonts") == 0)
PHYSFS_enumerate(fname, fontSetEnumCB, data);
return PHYSFS_ENUM_OK;
}
void FileSystem::initFontSets(SharedFontState &sfs)
{
FontSetsCBData d = { p, &sfs };
PHYSFS_enumerate("", findFontsFolderCB, &d);
PHYSFS_enumerateFilesCallback("Fonts", fontSetEnumCB, &d);
}
struct OpenReadEnumData
@ -570,19 +532,19 @@ struct OpenReadEnumData
{}
};
static PHYSFS_EnumerateCallbackResult
openReadEnumCB(void *d, const char *dirpath, const char *filename)
static void openReadEnumCB(void *d, const char *dirpath,
const char *filename)
{
OpenReadEnumData &data = *static_cast<OpenReadEnumData*>(d);
char buffer[512];
const char *fullPath;
if (data.stopSearching)
return PHYSFS_ENUM_STOP;
return;
/* If there's not even a partial match, continue searching */
if (strncmp(filename, data.filename, data.filenameN) != 0)
return PHYSFS_ENUM_OK;
return;
if (!*dirpath)
{
@ -600,7 +562,7 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename)
* of the extension), or up to a following '\0' (full match), we've
* found our file */
if (last != '.' && last != '\0')
return PHYSFS_ENUM_STOP;
return;
/* If the path cache is active, translate from lower case
* to mixed case path */
@ -615,9 +577,9 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename)
* be a deeper rooted problem somewhere within PhysFS.
* Just abort alltogether. */
data.stopSearching = true;
data.physfsError = PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode());
data.physfsError = PHYSFS_getLastError();
return PHYSFS_ENUM_ERROR;
return;
}
initReadOps(phys, data.ops, false);
@ -628,7 +590,6 @@ openReadEnumCB(void *d, const char *dirpath, const char *filename)
data.stopSearching = true;
++data.matchCount;
return PHYSFS_ENUM_OK;
}
void FileSystem::openRead(OpenHandler &handler, const char *filename)
@ -674,7 +635,7 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename)
}
else
{
PHYSFS_enumerate(dir, openReadEnumCB, &data);
PHYSFS_enumerateFilesCallback(dir, openReadEnumCB, &data);
}
if (data.physfsError)

View File

@ -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

View File

@ -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

View File

@ -6,6 +6,10 @@
#include "debugwriter.h"
#ifdef SHARED_FLUID
#include <fluidsynth.h>
#endif
#if __LINUX__ || __ANDROID__
#define FLUID_LIB "libfluidsynth.so.1"
#elif __MACOSX__

View File

@ -1,12 +1,6 @@
#ifndef FLUIDFUN_H
#define FLUIDFUN_H
#ifdef SHARED_FLUID
# include <fluidsynth.h>
#else
# define FLUIDSYNTH_VERSION_MAJOR 2
#endif
typedef struct _fluid_hashtable_t fluid_settings_t;
typedef struct _fluid_synth_t fluid_synth_t;
@ -25,12 +19,7 @@ typedef int (*FLUIDSYNTHPROGRAMCHANGEPROC)(fluid_synth_t* synth, int chan, int p
typedef fluid_settings_t* (*NEWFLUIDSETTINGSPROC)(void);
typedef fluid_synth_t* (*NEWFLUIDSYNTHPROC)(fluid_settings_t* settings);
typedef void (*DELETEFLUIDSETTINGSPROC)(fluid_settings_t* settings);
#if FLUIDSYNTH_VERSION_MAJOR == 1
typedef int (*DELETEFLUIDSYNTHPROC)(fluid_synth_t* synth);
#else
typedef void (*DELETEFLUIDSYNTHPROC)(fluid_synth_t* synth);
#endif
#define FLUID_FUNCS \
FLUID_FUN(settings_setnum, FLUIDSETTINGSSETNUMPROC) \

View File

@ -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,15 @@
#include <SDL_ttf.h>
#define BUNDLED_FONT liberation
#define BUNDLED_FONT_DECL(FONT) \
extern unsigned char assets_##FONT##_ttf[]; \
extern unsigned int assets_##FONT##_ttf_len;
BUNDLED_FONT_DECL(liberation)
#define BUNDLED_FONT_D(f) assets_## f ##_ttf
#define BUNDLED_FONT_L(f) assets_## f ##_ttf_len
#define BUNDLED_FONT_DECL(FONT) \
extern unsigned char BUNDLED_FONT_D(FONT)[]; \
extern unsigned int BUNDLED_FONT_L(FONT);
BUNDLED_FONT_DECL(BUNDLED_FONT)
// Go fuck yourself CPP
#define BNDL_F_D(f) BUNDLED_FONT_D(f)
#define BNDL_F_L(f) BUNDLED_FONT_L(f)
@ -184,7 +182,7 @@ _TTF_Font *SharedFontState::getFont(std::string family,
return font;
}
bool SharedFontState::fontPresent(std::string family) const
bool SharedFontState::fontPresent(std::string family)
{
/* Check for substitutions */
if (p->subs.contains(family))
@ -202,26 +200,6 @@ _TTF_Font *SharedFontState::openBundled(int size)
return TTF_OpenFontRW(ops, 1, size);
}
void pickExistingFontName(const std::vector<std::string> &names,
std::string &out,
const SharedFontState &sfs)
{
/* Note: In RMXP, a names array with no existing entry
* results in no text being drawn at all (same for "" and []);
* we can't replicate this in mkxp due to the default substitute. */
for (size_t i = 0; i < names.size(); ++i)
{
if (sfs.fontPresent(names[i]))
{
out = names[i];
return;
}
}
out = "";
}
struct FontPrivate
{
@ -249,15 +227,15 @@ struct FontPrivate
static Color defaultColorTmp;
static Color defaultOutColorTmp;
static std::vector<std::string> initialDefaultNames;
/* The actual font is opened as late as possible
* (when it is queried by a Bitmap), prior it is
* set to null */
TTF_Font *sdlFont;
FontPrivate(int size)
: size(size),
FontPrivate(const char *name = 0,
int size = 0)
: name(name ? std::string(name) : defaultName),
size(size ? size : defaultSize),
bold(defaultBold),
italic(defaultItalic),
outline(defaultOutline),
@ -310,8 +288,6 @@ Color *FontPrivate::defaultOutColor = &FontPrivate::defaultOutColorTmp;
Color FontPrivate::defaultColorTmp(255, 255, 255, 255);
Color FontPrivate::defaultOutColorTmp(0, 0, 0, 128);
std::vector<std::string> FontPrivate::initialDefaultNames;
bool Font::doesExist(const char *name)
{
if (!name)
@ -320,15 +296,10 @@ bool Font::doesExist(const char *name)
return shState->fontState().fontPresent(name);
}
Font::Font(const std::vector<std::string> *names,
Font::Font(const char *name,
int size)
{
p = new FontPrivate(size ? size : FontPrivate::defaultSize);
if (names)
setName(*names);
else
p->name = FontPrivate::defaultName;
p = new FontPrivate(name, size);
}
Font::Font(const Font &other)
@ -348,9 +319,17 @@ const Font &Font::operator=(const Font &o)
return o;
}
void Font::setName(const std::vector<std::string> &names)
const char *Font::getName() const
{
pickExistingFontName(names, p->name, shState->fontState());
return p->name.c_str();
}
void Font::setName(const char *value)
{
if (p->name == value)
return;
p->name = value;
p->sdlFont = 0;
}
@ -386,15 +365,14 @@ DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutline, bool, FontPrivate::defaultOutli
DEF_ATTR_SIMPLE_STATIC(Font, DefaultColor, Color&, *FontPrivate::defaultColor)
DEF_ATTR_SIMPLE_STATIC(Font, DefaultOutColor, Color&, *FontPrivate::defaultOutColor)
void Font::setDefaultName(const std::vector<std::string> &names,
const SharedFontState &sfs)
const char *Font::getDefaultName()
{
pickExistingFontName(names, FontPrivate::defaultName, sfs);
return FontPrivate::defaultName.c_str();
}
const std::vector<std::string> &Font::getInitialDefaultNames()
void Font::setDefaultName(const char *value)
{
return FontPrivate::initialDefaultNames;
FontPrivate::defaultName = value;
}
void Font::initDynAttribs()
@ -413,30 +391,8 @@ void Font::initDefaultDynAttribs()
FontPrivate::defaultOutColor = new Color(FontPrivate::defaultOutColorTmp);
}
void Font::initDefaults(const SharedFontState &sfs)
void Font::initDefaults()
{
std::vector<std::string> &names = FontPrivate::initialDefaultNames;
switch (rgssVer)
{
case 1 :
// FIXME: Japanese version has "MS PGothic" instead
names.push_back("Arial");
break;
case 2 :
names.push_back("UmePlus Gothic");
names.push_back("MS Gothic");
names.push_back("Courier New");
break;
default:
case 3 :
names.push_back("VL Gothic");
}
setDefaultName(names, sfs);
FontPrivate::defaultOutline = (rgssVer >= 3 ? true : false);
FontPrivate::defaultShadow = (rgssVer == 2 ? true : false);
}

View File

@ -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,9 +25,6 @@
#include "etc.h"
#include "util.h"
#include <vector>
#include <string>
struct SDL_RWops;
struct _TTF_Font;
struct Config;
@ -50,7 +47,7 @@ public:
_TTF_Font *getFont(std::string family,
int size);
bool fontPresent(std::string family) const;
bool fontPresent(std::string family);
static _TTF_Font *openBundled(int size);
@ -58,6 +55,22 @@ private:
SharedFontStatePrivate *p;
};
/* Concerning Font::name/defaultName :
* In RGSS, this is not actually a string; any type of
* object is accepted, however anything but strings and
* arrays is ignored (and text drawing turns blank).
* Single strings are interpreted as font family names,
* and directly passed to the underlying C++ object;
* arrays however are searched for the first string
* object corresponding to a valid font family name,
* and rendering is done with that. In mkxp, we pass
* this first valid font family as the 'name' attribute
* back to the C++ object on assignment and object
* creation (in case Font.default_name is also an array).
* Invalid parameters (things other than strings or
* arrays not containing any valid family name) are
* passed back as "". */
struct FontPrivate;
class Font
@ -65,43 +78,31 @@ class Font
public:
static bool doesExist(const char *name);
Font(const std::vector<std::string> *names = 0,
Font(const char *name = 0,
int size = 0);
/* Clone constructor */
Font(const Font &other);
~Font();
const Font &operator=(const Font &o);
DECL_ATTR( Size, int )
DECL_ATTR( Bold, bool )
DECL_ATTR( Italic, bool )
DECL_ATTR( Color, Color& )
DECL_ATTR( Shadow, bool )
DECL_ATTR( Outline, bool )
DECL_ATTR( OutColor, Color& )
DECL_ATTR( Name, const char * )
DECL_ATTR( Size, int )
DECL_ATTR( Bold, bool )
DECL_ATTR( Italic, bool )
DECL_ATTR( Color, Color& )
DECL_ATTR( Shadow, bool )
DECL_ATTR( Outline, bool )
DECL_ATTR( OutColor, Color& )
DECL_ATTR_STATIC( DefaultSize, int )
DECL_ATTR_STATIC( DefaultBold, bool )
DECL_ATTR_STATIC( DefaultItalic, bool )
DECL_ATTR_STATIC( DefaultColor, Color& )
DECL_ATTR_STATIC( DefaultShadow, bool )
DECL_ATTR_STATIC( DefaultOutline, bool )
DECL_ATTR_STATIC( DefaultOutColor, Color& )
/* There is no point in providing getters for these,
* as the bindings will always return the stored native
* string/array object anyway. It's impossible to mirror
* in the C++ core.
* The core object picks the first existing name from the
* passed array and stores it internally (same for default). */
void setName(const std::vector<std::string> &names);
static void setDefaultName(const std::vector<std::string> &names,
const SharedFontState &sfs);
static const std::vector<std::string> &getInitialDefaultNames();
DECL_ATTR_STATIC( DefaultName, const char* )
DECL_ATTR_STATIC( DefaultSize, int )
DECL_ATTR_STATIC( DefaultBold, bool )
DECL_ATTR_STATIC( DefaultItalic, bool )
DECL_ATTR_STATIC( DefaultColor, Color& )
DECL_ATTR_STATIC( DefaultShadow, bool )
DECL_ATTR_STATIC( DefaultOutline, bool )
DECL_ATTR_STATIC( DefaultOutColor, Color& )
/* Assigns heap allocated objects to object properties;
* using this in pure C++ will cause memory leaks
@ -109,7 +110,7 @@ public:
void initDynAttribs();
static void initDefaultDynAttribs();
static void initDefaults(const SharedFontState &sfs);
static void initDefaults();
/* internal */
_TTF_Font *getSdlFont();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -23,7 +23,6 @@
#include "shader.h"
#include "etc.h"
#include "gl-fun.h"
#include "config.h"
#include <SDL_rect.h>
@ -84,9 +83,10 @@ void GLBlendMode::apply(const BlendType &value)
break;
case BlendSubstraction :
// FIXME Alpha calculation is untested
gl.BlendEquation(GL_FUNC_REVERSE_SUBTRACT);
gl.BlendFuncSeparate(GL_SRC_ALPHA, GL_ONE,
GL_ZERO, GL_ONE);
GL_ONE, GL_ONE);
break;
}
}
@ -111,7 +111,7 @@ GLState::Caps::Caps()
gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
}
GLState::GLState(const Config &conf)
GLState::GLState()
{
gl.Disable(GL_DEPTH_TEST);
@ -121,7 +121,4 @@ GLState::GLState(const Config &conf)
scissorTest.init(false);
scissorBox.init(IntRect(0, 0, 640, 480));
program.init(0);
if (conf.maxTextureSize > 0)
caps.maxTexSize = conf.maxTextureSize;
}

View File

@ -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,8 +27,6 @@
#include <stack>
#include <assert.h>
struct Config;
template<typename T>
struct GLProperty
{
@ -132,7 +130,7 @@ public:
} caps;
GLState(const Config &conf);
GLState();
};
#endif // GLSTATE_H

Some files were not shown because too many files have changed in this diff Show More