mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-20 13:59:57 +00:00
h
This commit is contained in:
parent
a81aa34411
commit
e29a3c366c
18 changed files with 43 additions and 51 deletions
|
|
@ -1,6 +1,13 @@
|
|||
#include <ruby.h>
|
||||
#include <SDL3/SDL_version.h>
|
||||
|
||||
static VALUE string_clone(VALUE self){
|
||||
if (!RB_TYPE_P(self, T_STRING)) {
|
||||
rb_raise(rb_eTypeError, "wrong argument type (expected String)");
|
||||
}
|
||||
return rb_obj_clone(self);
|
||||
}
|
||||
|
||||
void SunshineBindingInit(){
|
||||
printf("[SunshineBindingInit] Initializing Sunshine binding\n");
|
||||
VALUE module = rb_define_module("Sunshine");
|
||||
|
|
@ -8,6 +15,7 @@ void SunshineBindingInit(){
|
|||
rb_const_set(module, rb_intern("SDLVersion_minor"), INT2NUM(SDL_MINOR_VERSION));
|
||||
rb_const_set(module, rb_intern("SDLVersion_micro"), INT2NUM(SDL_MICRO_VERSION));
|
||||
rb_define_method(rb_cObject, "class", rb_obj_class, 0);
|
||||
rb_define_method(rb_cString, "clone", RUBY_METHOD_FUNC(string_clone), 0);
|
||||
printf("[SunshineBindingInit] SDL version: %i.%i.%i\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_MICRO_VERSION);
|
||||
printf("[SunshineBindingInit] Done\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class Interpreter
|
|||
else
|
||||
is_doc = false
|
||||
end
|
||||
loop do
|
||||
while true
|
||||
# 401: another line of text
|
||||
if @list[@index+1].code == 401
|
||||
@index += 1
|
||||
|
|
@ -363,7 +363,7 @@ class Interpreter
|
|||
# Get indent
|
||||
indent = @list[@index].indent
|
||||
# Loop
|
||||
loop do
|
||||
while true
|
||||
# Return index
|
||||
@index -= 1
|
||||
# If this event command is the same level as indent
|
||||
|
|
@ -382,7 +382,7 @@ class Interpreter
|
|||
# Copy index to temporary variables
|
||||
temp_index = @index
|
||||
# Loop
|
||||
loop do
|
||||
while true
|
||||
# Advance index
|
||||
temp_index += 1
|
||||
# If a fitting loop was not found
|
||||
|
|
@ -453,7 +453,7 @@ class Interpreter
|
|||
# Initialize temporary variables
|
||||
temp_index = 0
|
||||
# Loop
|
||||
loop do
|
||||
while true
|
||||
# If a fitting label was not found
|
||||
if temp_index >= @list.size-1
|
||||
# Continue
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class Interpreter
|
|||
# Set goods list on new item
|
||||
$game_temp.shop_goods = [@parameters]
|
||||
# Loop
|
||||
loop do
|
||||
while true
|
||||
# Advance index
|
||||
@index += 1
|
||||
# If next event command has shop on second line or after
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ class Interpreter
|
|||
# Set first line to script
|
||||
script = @list[@index].parameters[0] + "\n"
|
||||
# Loop
|
||||
loop do
|
||||
while true
|
||||
# If next event command is second line of script or after
|
||||
if @list[@index+1].code == 655
|
||||
# Add second line or after to script
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class Scene_Debug
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Scene_End
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Scene_Equip
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Scene_File
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class Scene_Item
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Scene_Map
|
|||
# Transition run
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
@ -112,7 +112,7 @@ class Scene_Map
|
|||
total_sec * 1000 % 1000)
|
||||
|
||||
@in_game_timer.bitmap.fill_rect(0, 0, 140, 30, Color.new(0, 0, 0, 128))
|
||||
@in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string)
|
||||
#@in_game_timer.bitmap.draw_text(8, 0, 132, 30, time_string)
|
||||
end
|
||||
|
||||
if Input.quit?
|
||||
|
|
@ -132,7 +132,7 @@ class Scene_Map
|
|||
end
|
||||
end
|
||||
# Loop
|
||||
loop do
|
||||
while true
|
||||
if $game_temp.prompt_wait > 0
|
||||
$game_temp.prompt_wait -= 1
|
||||
return
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Scene_Menu
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Scene_Name
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Scene_Skill
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Scene_Status
|
|||
# Execute transition
|
||||
Graphics.transition
|
||||
# Main loop
|
||||
loop do
|
||||
while true
|
||||
# Update game screen
|
||||
Graphics.update
|
||||
# Update input information
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ class Sprite_Timer < Sprite
|
|||
sec = @total_sec % 60
|
||||
text = sprintf("%02d:%02d", min, sec)
|
||||
# Draw timer
|
||||
self.bitmap.font.color.set(255, 255, 255)
|
||||
self.bitmap.draw_text(self.bitmap.rect, text, 1)
|
||||
#self.bitmap.font.color.set(255, 255, 255)
|
||||
#self.bitmap.draw_text(self.bitmap.rect, text, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Window_MainMenu < Window_Selectable
|
|||
# Update item
|
||||
rect = Rect.new(w * index, 0, w - 32, 32)
|
||||
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
|
||||
self.contents.draw_text(rect, tr(@commands[index]), 1)
|
||||
#self.contents.draw_text(rect, tr(@commands[index]), 1)
|
||||
end
|
||||
#--------------------------------------------------------------------------
|
||||
# * Disable Item
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ class Window_NameInput < Window_Base
|
|||
if old_slot == 0
|
||||
@index = @table_size + @table_width - 1
|
||||
else
|
||||
loop do
|
||||
while true
|
||||
@index -= 1
|
||||
break if old_slot != mode_button_slot
|
||||
end
|
||||
|
|
@ -199,7 +199,7 @@ class Window_NameInput < Window_Base
|
|||
if old_slot == -1
|
||||
@index = @table_size
|
||||
else
|
||||
loop do
|
||||
while true
|
||||
@index += 1
|
||||
break if old_slot != mode_button_slot
|
||||
end
|
||||
|
|
|
|||
40
src/font.cpp
40
src/font.cpp
|
|
@ -33,8 +33,7 @@
|
|||
|
||||
typedef std::pair<std::string, int> FontKey;
|
||||
|
||||
struct FontSet
|
||||
{
|
||||
struct FontSet{
|
||||
/* 'Regular' style */
|
||||
std::string regular;
|
||||
|
||||
|
|
@ -42,8 +41,7 @@ struct FontSet
|
|||
std::string other;
|
||||
};
|
||||
|
||||
struct SharedFontStatePrivate
|
||||
{
|
||||
struct SharedFontStatePrivate{
|
||||
/* Maps: font family name, To: substituted family name,
|
||||
* as specified via configuration file / arguments */
|
||||
BoostHash<std::string, std::string> subs;
|
||||
|
|
@ -57,13 +55,11 @@ struct SharedFontStatePrivate
|
|||
BoostHash<FontKey, TTF_Font*> pool;
|
||||
};
|
||||
|
||||
SharedFontState::SharedFontState(const Config &conf)
|
||||
{
|
||||
SharedFontState::SharedFontState(const Config &conf){
|
||||
p = new SharedFontStatePrivate;
|
||||
|
||||
/* Parse font substitutions */
|
||||
for (size_t i = 0; i < conf.fontSubs.size(); ++i)
|
||||
{
|
||||
for (size_t i = 0; i < conf.fontSubs.size(); ++i){
|
||||
const std::string &raw = conf.fontSubs[i];
|
||||
size_t sepPos = raw.find_first_of('>');
|
||||
|
||||
|
|
@ -77,8 +73,7 @@ SharedFontState::SharedFontState(const Config &conf)
|
|||
}
|
||||
}
|
||||
|
||||
SharedFontState::~SharedFontState()
|
||||
{
|
||||
SharedFontState::~SharedFontState(){
|
||||
BoostHash<FontKey, TTF_Font*>::const_iterator iter;
|
||||
for (iter = p->pool.cbegin(); iter != p->pool.cend(); ++iter)
|
||||
TTF_CloseFont(iter->second);
|
||||
|
|
@ -86,9 +81,7 @@ SharedFontState::~SharedFontState()
|
|||
delete p;
|
||||
}
|
||||
|
||||
void SharedFontState::initFontSetCB(SDL_IOStream* &ops,
|
||||
const std::string &filename)
|
||||
{
|
||||
void SharedFontState::initFontSetCB(SDL_IOStream* &ops, const std::string &filename){
|
||||
TTF_Font *font = TTF_OpenFontIO(ops, false, 0);
|
||||
|
||||
if (!font)
|
||||
|
|
@ -107,9 +100,7 @@ void SharedFontState::initFontSetCB(SDL_IOStream* &ops,
|
|||
set.other = filename;
|
||||
}
|
||||
|
||||
TTF_Font *SharedFontState::getFont(std::string family,
|
||||
int size)
|
||||
{
|
||||
TTF_Font *SharedFontState::getFont(std::string family, int size){
|
||||
/* Check for substitutions */
|
||||
if (p->subs.contains(family))
|
||||
family = p->subs[family];
|
||||
|
|
@ -133,9 +124,7 @@ TTF_Font *SharedFontState::getFont(std::string family,
|
|||
|
||||
if (family.empty()){
|
||||
throw Exception(Exception::RGSSError, "font does not exist");
|
||||
}
|
||||
else
|
||||
{
|
||||
}else{
|
||||
/* Use 'other' path as alternative in case
|
||||
* we have no 'regular' styled font asset */
|
||||
const char *path = !req.regular.empty()
|
||||
|
|
@ -173,10 +162,8 @@ void pickExistingFontName(const std::vector<std::string> &names,
|
|||
* 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]))
|
||||
{
|
||||
for (size_t i = 0; i < names.size(); ++i){
|
||||
if (sfs.fontPresent(names[i])){
|
||||
out = names[i];
|
||||
return;
|
||||
}
|
||||
|
|
@ -281,8 +268,7 @@ bool Font::doesExist(const char *name){
|
|||
}
|
||||
|
||||
Font::Font(const std::vector<std::string> *names,
|
||||
int size)
|
||||
{
|
||||
int size){
|
||||
p = new FontPrivate(size ? size : FontPrivate::defaultSize);
|
||||
|
||||
if (names)
|
||||
|
|
@ -341,9 +327,7 @@ 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)
|
||||
{
|
||||
void Font::setDefaultName(const std::vector<std::string> &names, const SharedFontState &sfs){
|
||||
pickExistingFontName(names, FontPrivate::defaultName, sfs);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue