Commit Graph

51 Commits

Author SHA1 Message Date
Jonas Kulla 1ef6e04520 Font: Overhaul font asset discovery
Previously, any font names requested by RGSS would be translated
directly to filenames by lowercasing and replacing spaces with
underscores (and finally doing some extension substitution).
To make this whole thing work smoother as well as get closer to
how font discovery is done in VX, we now scan the "Fonts/" folder
at startup and index all present font assets by their family name;
now, if an "Open Sans" font is present in "Fonts/", it will be
used regardless of filename.

Font assets with "Regular" style are preferred, but in their
absence, mkxp will make use of any other style it can find for
the respective family. This is not the exact same behavior as
VX, but it should cover 95% of use cases.

Previously, one could substitute fonts via filenames, ie. to
substitute "Arial" with "Open Sans", one would just rename
"OpenSans.ttf" to "arial.ttf" and put it in "Fonts/". With the
above change, this is no longer possible. As an alternative, one
can now explicitly specify font family substitutions via mkxp.conf;
eg. for the above case, one would add

fontSub=Arial>Open Sans

to the configuration file. Multiple such rules can be specified.

In the process, I also added the ability to provide
'Font.(default_)name' with an array of font families to search
for the first existing one instead of a plain string.
This makes the behavior closer to RMXP; however, it doesn't
work 100% the same: when a reference to the 'Font.name' array is
held and additional strings are added to it without re-assignig
the array to 'Font.name', those will be ignored.
2014-04-16 13:37:22 +02:00
Jonas Kulla 6dfa4f6b7d MRI-Binding: Add 'Graphics.width/height' bindings (RGSS2) 2014-04-11 13:34:19 +02:00
Jonas Kulla 8203e32900 MRI-Binding: Define 'msgbox' p/print aliases (RGSS3) 2014-04-11 13:31:09 +02:00
Jonas Kulla af9039f58d Sprite: Implement wave effect (RGSS2)
This initial implementation emulates the way RMVX splits
the sprite into "chunks" of about 8 pixels, which it then
scrolls left/right on a vertical sine wave. It even
replicates the weird behavior when wave_amp < 0, namely
"shrinking" the src_rect horizontally.

As with bush_opacity, this effect in combination with
rotation will render differently from RMVX.
2014-02-03 15:32:50 +01:00
Jonas Kulla 64f1e32fdc Input: Implement RGSS3 functionality in bindings
Ie. using symbols instead of Input:: constants to query
button states.
2014-02-03 15:04:57 +01:00
Jonas Kulla e0a4dfe372 Bitmap: Make #get_pixel/#set_pixel more accurate
This gets rid of the "batch/flush" semantics for #set_pixel
and instead just directly uploads the pixel color to the
texture, circumventing the float conversion entirely.
Also makes a lot of code simpler in many places as calling
'flush()' is no longer required for bitmaps.
2014-01-31 10:19:16 +01:00
Jonas Kulla a0a27889a3 Merge #8 2014-01-02 00:11:57 +01:00
Edward Rudd 5c0295e972 use correct macros in ruby code so code compiles in 32bit and 64bit mode 2014-01-01 11:20:42 -05:00
Jonas Kulla 1bacceddf0 Spacing 2014-01-01 12:59:40 +01:00
Edward Rudd 4a817f45e5 wrap not check in parenthesis so the check is done correctly. 2013-12-31 16:26:10 -05:00
Edward Rudd 2572a05e8b safely print errors by explicitly specifying a format string 2013-12-31 16:25:38 -05:00
Edward Rudd adfbc5bb64 pull in missing include 2013-12-31 16:25:13 -05:00
Edward Rudd 5b4e512dc6 ulong isn't defined anywhere (maybe on linux it is.. but not standard on OS X) 2013-12-31 16:24:56 -05:00
Jonas Kulla 9759e52b3c Exception: Constructor now takes printf style arguments 2013-12-29 18:05:11 +01:00
Jonas Kulla 7f4e58fd6e MRI-Binding: Don't memcpy script data before deflating
I think the reason this was originally done was some
issue with ruby's GC where it would wrongfully sweep
the script array variable on the C stack.

This change should speed up startup a little.
2013-12-29 14:55:49 +01:00
Jonas Kulla 2adf8ab265 Transition from QtCore to stdc++ / STL / boost
This looks like a pretty major change, but in reality,
80% of it is just renames of types and corresponding
methods.

The config parsing code has been completely replaced
with a boost::program_options based version. This
means that the config file format slightly changed
(checkout the updated README).

I still expect there to be bugs / unforseen events.
Those should be fixed in follow up commits.

Also, finally reverted back to using pkg-config to
locate and link libruby. Yay for less hacks!
2013-12-29 13:59:26 +01:00
Jonas Kulla 231e38ae8e Replace QVector, QList with std::vector, std::list
An exception is made of TexPool, which will need a
bit more testing before transitioning to std containers.

Also replace 'int' with 'size_t' where it is used only
as an array index.
2013-12-26 20:18:33 +01:00
Jonas Kulla c504a383ba MRI-Binding: Optimize RB_ARG_END vaarg guard
It's enough to check this only in debug mode.
Make this an empty define in release mode.
2013-12-20 11:29:12 +01:00
Jonas Kulla d7ceff91a2 MRI-Binding: Deduplicate code 2013-12-20 10:22:01 +01:00
Jonas Kulla 7e943e2803 MRI-Binding: Optimize attribute setters 2013-12-18 17:36:45 +01:00
Jonas Kulla 91c5eb1861 MRI-Binding: Fix typo that led to access of freed Color objects
Also fix my moronic variable naming in the InitCopy
functions that let to this mess up in the first place.
2013-12-15 10:18:58 +01:00
Jonas Kulla 94119baeee MRI-Binding: Add 'ViewportElement.viewport=' binding 2013-12-06 15:56:38 +01:00
Jonas Kulla ef2430e0c3 Sanitize #include statements
The general rule I'm aiming for is to <> include
system wide / installed paths / generally everything
that's outside the git managed source tree (this means
mruby paths too!), and "" include everything else,
ie. local mkxp headers.

The only current exception are the mri headers, which
all have './' at their front as to not clash with
system wide ruby headers. I'm leaving them be for now
until I can come up with a better general solution.
2013-12-04 17:48:37 +01:00
Jonas Kulla b5d1172350 MRI-Binding: Silence "may be uninitialized" warnings 2013-11-30 14:46:45 +01:00
Jonas Kulla 5863e14953 MRI-Binding: Bitmap: Add FIXME 2013-11-01 08:37:27 +01:00
Jonas Kulla 3359451f3a MRI-Binding: Catch exceptions in clone constructors 2013-10-31 10:25:54 +01:00
Jonas Kulla b7a2ba830c MRI-Binding: Bind #initialize_copy for clonable classes
This replaces the previously directly bound #clone
methods, which weren't really the "the Ruby way".
Rubys default Object#clone will call into our #init_copy
methods instead.

Partly incorporates pull request #3 by /cremno.
2013-10-31 10:13:24 +01:00
Jonas Kulla f067e0eff8 MRI-Binding: Reduce number of object allocations
Previously, wrapped instances of mkxp core classes were
stored as RData ivars inside the actual object. This turned
out to be pointless as RData objects themselves are perfectly
valid objects that can carry ivars and have parent classes.
Therefore, the RData objects are now exposed directly to
the user scripts, effectively halving the amount of object
allocations.
2013-10-30 10:06:24 +01:00
cremno 8c45a5b11e follow-up: style adjustments (see GH-2) 2013-10-22 15:24:55 +02:00
cremno 071ad5d961 MRI: changes to mkxp's Marshal::load monkey patch
- force string encoding to UTF-8 only when it's ASCII-8BIT (force only valid UTF-8 strings in future?)

- support original Marshal::load proc (2nd arg)
2013-10-22 13:45:57 +02:00
Jonas Kulla aa786e268d Remove unused code 2013-10-20 21:04:30 +02:00
Jonas Kulla 27341dc95d MRI-Binding: Enforce UTF-8 strings in 'Marshal::load()' via aux proc
We override 'Marshal::load()' via alias and call it with
a custom auxiliary proc in the alias which sets the encoding
of all demarshalled strings to UTF-8. The case where a user
himself provided a proc to 'load()' is not implemented.

This is definitely a better solution than patching the ruby
source tree. Thanks to github.com/cremno for hints and help!
2013-10-20 20:54:56 +02:00
Jonas Kulla 30507d2f6f MRI-Binding: Enforce UTF-8 string encoding 2013-10-19 18:57:34 +02:00
Jonas Kulla d5bc71f7ba MRI-Binding: Add 'System.puts()' for console printing 2013-10-19 15:54:21 +02:00
Jonas Kulla 1759a1b4a9 MRI-Binding: Fix Audio fade functions all fading the BGM 2013-10-17 01:02:09 +02:00
Jonas Kulla 26bc4842c0 MRI-Binding: Catch exceptions in '_load' implementations 2013-10-15 05:12:20 +02:00
Jonas Kulla 39436ad231 Fix up SDL2 include paths
Using "SDL2/SDL_xxx.h" instead of "SDL_xxx.h" caused
the include paths provided by pkg-config to be ignored,
and headers from a standard include path to be used instead.
2013-10-13 23:21:34 +02:00
Jonas Kulla cb6f73f7df Rename 'GlobalState' to 'SharedState' to avoid confusion with GLState
This was particularly nasty with the shorthand macros
'gState' and 'glState'. The former is now 'shState'.
2013-10-09 12:30:33 +02:00
Jonas Kulla 6fef49f42a Cosmetic fixes 2013-10-08 06:05:06 +02:00
Jonas Kulla a108843069 Add 'System.data_directory()' for save files etc.
Just a small wrapper around SDL2's GetPrefPath()
2013-10-08 06:04:21 +02:00
Jonas Kulla dd25323cdd Ifdef out more RGSS2 functionality 2013-10-06 10:28:03 +02:00
Jonas Kulla ce70b6dc95 Fix a heavy memory corruption in p()/print()
If you free locally allocated ruby objects
you're gonna have a BAAAD time
2013-10-06 10:19:31 +02:00
Jonas Kulla 4ff563725b Make 'rb_get_args()' va_arg passing safer by introducing a termination marker
What can I say. I made a pact with the devil, and paid dearly.
Almost a whole day's worth of debugging, actually. Not again.

If this turns out to be slow we can always optimize the critical
parts (with no variable param count) later, or completely remove it.
2013-09-27 04:49:48 +02:00
Jonas Kulla fe557bca1d Implement "show_cursor" attribute in Graphics module
If false (the default), the system cursor is hidden
inside the game window.
2013-09-24 22:56:25 +02:00
Jonas Kulla e42e6398cb Add FIXME 2013-09-10 04:21:57 +02:00
Jonas Kulla f87f231129 Fix Plane not accepting nil for '#bitmap=' 2013-09-06 15:54:30 +02:00
Jonas Kulla f81e20cc68 Raise exception on too big textures 2013-09-03 15:22:00 +02:00
Jonas Kulla 73812e957e Clean up unused code 2013-09-03 14:39:11 +02:00
Jonas Kulla 57a8f772c8 Remove leftover junk 2013-09-01 16:39:22 +02:00
Jonas Kulla 88041a2395 Check if RMXP script pack path was read from Game.ini 2013-09-01 16:36:11 +02:00