overbound / SonicTimeTwisted

Source Code for a Sonic Fan Game Made in Game Maker Studio
https://overboundstudio.com/
GNU General Public License v3.0
58 stars 16 forks source link

JSON Translations. #67

Closed nkrapivin closed 4 years ago

nkrapivin commented 4 years ago

It's similar to a thing I've wrote for ASTRA-256.

Also I've enabled Fast Collision System in Android config because it's using R-Trees and not just looping through all instances which helps performance on mobile.

Oh and OUYA is dead so I disabled OUYA packaging.

AlexKhayrullin commented 4 years ago

This is something I was planning on working on after the 1.0 version is done, it has been a bit low-priority. Thanks for the effort :) .

Three comments:

nkrapivin commented 4 years ago

Look at the TODO in objResources, I am planning on implementing that.

Also GameMaker: Studio supports unicode and as such Russian/Ukrainian/Whatever just fine, Надо просто указать в настройках шрифта алфавит: АаБбВвГгДдЕеЁеЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя For Russian. :)

AlexKhayrullin commented 4 years ago

That, I know ;) . I've done it before (https://twitter.com/AlexKhayrullin/status/762023868840239104 , oh the memories :) ).

I just thought I'd somehow allow to create translations without the need to download the source and use GameMaker Studio (because while the project is open source, GM:S is not, on top of being discontinued and no longer available for purchase) , kinda allow to create redistributable language packs which would include a JSON and PNG files with missing characters and another file that would explain what characters they match with.

nkrapivin commented 4 years ago

how 2 external fonts: Sprarr[1337] = sprite_add("somefont.png", amount_of_glyphs, false, false, 0, 0); Fontarr[1337] = font_add_sprite_ext(Sprarr[1337], "АаБбВвГг........", false, sep_width);

Done.

nkrapivin commented 4 years ago

You just gotta make the font a wide png file with all frames in one row.

AlexKhayrullin commented 4 years ago

Except that requires including the original font as well, that's what I was having a problem with. But hey, if there's no choice, there's no choice :) .

nkrapivin commented 4 years ago

You can include russian letters only, just don't use any English characters in the translation.

nkrapivin commented 4 years ago

Actually you can try sprite_add_from_surface, it can append subimages to sprites...

nkrapivin commented 4 years ago

Let me implement that.

AlexKhayrullin commented 4 years ago

I wouldn't like not being able to use English letters, if only because of some screens like the disclaimer that points to the Github repository, or the key/gamepad mapping screen, need latin letters.

The alternative would be to replace them systematically and display stuff like "гитхаб.ком/овербаунд/СоникТаймТвистед", and that just screams "90s pirate translation" :)

nkrapivin commented 4 years ago

соник тайм твистед перевод от фаргуса скачать бесплатно

Fair, but the project file is available to everyone anyway, so bundling the original font is not an issue.

I'll try sprite_add_from_surface

AlexKhayrullin commented 4 years ago

Yes, you're right. So if you don't manage to do this with sprite_add_from_surface, then no big deal, fonts will just need to include the original letters as well, and that will be it.

nkrapivin commented 4 years ago

___________________________________________
############################################################################################
ERROR in
action number 1
of Key Press Event for A-key Key
for object obj_test:

sprite_add_from_surface() requires the destination sprite to have been duplicated
 at gml_Object_obj_test_KeyPressed_A_1 (line 15) -     sprite_add_from_surface(sprite_index, _surf, i * _lettersw, 0, _lettersw, sprite_get_height(_spr), false, false);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_test_KeyPressed_A_1 (line 15)

ah, GameMaker requires the sprite to be duplicated, that would've been okay if not one weird issue. when you call sprite_add or any function that loads an image as a sprite or duplicates it into memory, instead of putting all frames on a single texture page, it will make a new texture page for each frame.

even if you call sprite_replace and you replace some sprite to a copy of it (width/height/amount of frames are equal), it will still make new texture pages for each frame..........................................

this is very very very inefficient especially on mobile.

nkrapivin commented 4 years ago

the code is something like this:

var _f = "spr_appendtemp_strip4.png";

sprite_index = sprite_duplicate(sprite_index); // <-- this line.

// load image strip as a one big wide sprite.
var _spr = sprite_add(_f, 1, false, false, 0, 0);

// make a surface of the exact same size.
var _surf = surface_create(sprite_get_width(_spr), sprite_get_height(_spr));

// draw the sprite on that surface.
surface_set_target(_surf);
draw_clear_alpha(c_black, 0);
draw_sprite(_spr, 0, 0, 0);
surface_reset_target();

var _letters = 4; // actual amount of letters. this is the thing you need to configure.
var _lettersw = sprite_get_width(_spr) / _letters; // width of one letter.
var _h = sprite_get_height(_spr);

sprite_delete(_spr); // we don't need the sprite anymore.

for (var i = 0; i < _letters; i++) {
    sprite_add_from_surface(sprite_index, _surf, i * _lettersw, 0, _lettersw, _h, false, false);
}

surface_free(_surf);

// we're done here.

but if you look at the debugger and then open Surfaces/Textures you can see that for each new appended frame GameMaker made a new page.

AlexKhayrullin commented 4 years ago

OK, if it's inefficient, then no big deal, we'll make the translators duplicate the fonts in their entirety.

Thanks a lot!

nkrapivin commented 4 years ago

It would've been better if STT fonts were in TTF. GameMaker pre-renders all TTF glyphs onto a single page.

nkrapivin commented 4 years ago

image

still waiting for a russian font...

AlexKhayrullin commented 4 years ago

Honestly, I'd rather leave them as sprites. Editing sprites is much more accessible than editing TTF fonts.

Just a warning if you're starting work on a Cyrillic font: the basic font as it is right now is incomplete (I want to at least cover the entirety of the ASCII set) , and there is another font very similar to it, but with letters slightly reduced named sprFontHudMin, which I then want to edit to include the same characters, it is used in menus on out-of-focus items.

nkrapivin commented 4 years ago

Yeah I'd leave them as sprites too...

AlexKhayrullin commented 4 years ago

I didn't exactly pay attention to it before merging (my bad, had just woken up ^^, and it's easy to miss) , but any reasons why you bumped up Android SDK versions?