mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-09-10 12:02:53 +02:00
parent
6c5616f65a
commit
a0da0df6ef
10 changed files with 49 additions and 17 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "audio/audio.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
#include "display/graphics.h"
|
||||
#include "display/font.h"
|
||||
#include "system/system.h"
|
||||
|
||||
#include "util/util.h"
|
||||
|
@ -136,6 +137,9 @@ RB_METHOD(mkxpAddPath);
|
|||
RB_METHOD(mkxpRemovePath);
|
||||
RB_METHOD(mkxpLaunch);
|
||||
|
||||
RB_METHOD(mkxpGetDefaultFontFamily);
|
||||
RB_METHOD(mkxpSetDefaultFontFamily);
|
||||
|
||||
RB_METHOD(mriRgssMain);
|
||||
RB_METHOD(mriRgssStop);
|
||||
RB_METHOD(_kernelCaller);
|
||||
|
@ -243,6 +247,8 @@ static void mriBindingInit() {
|
|||
_rb_define_module_function(mod, "unmount", mkxpRemovePath);
|
||||
_rb_define_module_function(mod, "launch", mkxpLaunch);
|
||||
|
||||
_rb_define_module_function(mod, "default_font_family=", mkxpSetDefaultFontFamily);
|
||||
|
||||
_rb_define_method(rb_cString, "to_utf8", mkxpStringToUTF8);
|
||||
_rb_define_method(rb_cString, "to_utf8!", mkxpStringToUTF8Bang);
|
||||
|
||||
|
@ -577,6 +583,19 @@ RB_METHOD(mkxpRemovePath) {
|
|||
return path;
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpSetDefaultFontFamily) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
VALUE familyV;
|
||||
rb_scan_args(argc, argv, "1", &familyV);
|
||||
SafeStringValue(familyV);
|
||||
|
||||
std::string family(RSTRING_PTR(familyV));
|
||||
shState->fontState().setDefaultFontFamily(family);
|
||||
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
RB_METHOD(mkxpStringToUTF8) {
|
||||
RB_UNUSED_PARAM;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ RB_METHOD(fontInitialize) {
|
|||
|
||||
wrapProperty(self, &f->getColor(), "color", ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
//if (rgssVer >= 3)
|
||||
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
|
||||
|
||||
return self;
|
||||
|
@ -117,7 +117,7 @@ RB_METHOD(fontInitializeCopy) {
|
|||
|
||||
wrapProperty(self, &f->getColor(), "color", ColorType);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
//if (rgssVer >= 3)
|
||||
wrapProperty(self, &f->getOutColor(), "out_color", ColorType);
|
||||
|
||||
return self;
|
||||
|
@ -262,7 +262,7 @@ void fontBindingInit() {
|
|||
|
||||
rb_iv_set(klass, "default_name", defNamesObj);
|
||||
|
||||
if (rgssVer >= 3)
|
||||
//if (rgssVer >= 3)
|
||||
wrapProperty(klass, &Font::getDefaultOutColor(), "default_out_color",
|
||||
ColorType);
|
||||
|
||||
|
@ -272,14 +272,14 @@ void fontBindingInit() {
|
|||
INIT_KLASS_PROP_BIND(Font, DefaultItalic, "default_italic");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultColor, "default_color");
|
||||
|
||||
if (rgssVer >= 2) {
|
||||
//if (rgssVer >= 2) {
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultShadow, "default_shadow");
|
||||
}
|
||||
//}
|
||||
|
||||
if (rgssVer >= 3) {
|
||||
//if (rgssVer >= 3) {
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutline, "default_outline");
|
||||
INIT_KLASS_PROP_BIND(Font, DefaultOutColor, "default_out_color");
|
||||
}
|
||||
//}
|
||||
|
||||
rb_define_class_method(klass, "exist?", fontDoesExist);
|
||||
|
||||
|
@ -292,12 +292,12 @@ void fontBindingInit() {
|
|||
INIT_PROP_BIND(Font, Italic, "italic");
|
||||
INIT_PROP_BIND(Font, Color, "color");
|
||||
|
||||
if (rgssVer >= 2) {
|
||||
//if (rgssVer >= 2) {
|
||||
INIT_PROP_BIND(Font, Shadow, "shadow");
|
||||
}
|
||||
//}
|
||||
|
||||
if (rgssVer >= 3) {
|
||||
//if (rgssVer >= 3) {
|
||||
INIT_PROP_BIND(Font, Outline, "outline");
|
||||
INIT_PROP_BIND(Font, OutColor, "out_color");
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -2013,7 +2013,7 @@
|
|||
3BDB22EC25644FBF00C4A63D /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 1330;
|
||||
LastUpgradeCheck = 1340;
|
||||
TargetAttributes = {
|
||||
3B1C235525A199370075EF5D = {
|
||||
CreatedOnToolsVersion = 12.3;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1330"
|
||||
LastUpgradeVersion = "1340"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1330"
|
||||
LastUpgradeVersion = "1340"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1330"
|
||||
LastUpgradeVersion = "1340"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1330"
|
||||
LastUpgradeVersion = "1340"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1330"
|
||||
LastUpgradeVersion = "1340"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -101,6 +101,10 @@ struct SharedFontStatePrivate
|
|||
/* Pool of already opened fonts; once opened, they are reused
|
||||
* and never closed until the termination of the program */
|
||||
BoostHash<FontKey, TTF_Font*> pool;
|
||||
|
||||
/* Internal default font family that is used anytime an
|
||||
* empty/invalid family is requested */
|
||||
std::string defaultFamily;
|
||||
};
|
||||
|
||||
SharedFontState::SharedFontState(const Config &conf)
|
||||
|
@ -156,6 +160,10 @@ void SharedFontState::initFontSetCB(SDL_RWops &ops,
|
|||
_TTF_Font *SharedFontState::getFont(std::string family,
|
||||
int size)
|
||||
{
|
||||
|
||||
if (family.empty())
|
||||
family = p->defaultFamily;
|
||||
|
||||
/* Check for substitutions */
|
||||
if (p->subs.contains(family))
|
||||
family = p->subs[family];
|
||||
|
@ -226,6 +234,10 @@ _TTF_Font *SharedFontState::openBundled(int size)
|
|||
return TTF_OpenFontRW(ops, 1, size);
|
||||
}
|
||||
|
||||
void SharedFontState::setDefaultFontFamily(const std::string &family) {
|
||||
p->defaultFamily = family;
|
||||
}
|
||||
|
||||
void pickExistingFontName(const std::vector<std::string> &names,
|
||||
std::string &out,
|
||||
const SharedFontState &sfs)
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
bool fontPresent(std::string family) const;
|
||||
|
||||
static _TTF_Font *openBundled(int size);
|
||||
void setDefaultFontFamily(const std::string &family);
|
||||
|
||||
private:
|
||||
SharedFontStatePrivate *p;
|
||||
|
|
Loading…
Add table
Reference in a new issue