[Deploying: (Browser, Android, Ios)]: proper way to save a config file?

Unqou

Veteran
Veteran
Joined
Mar 28, 2016
Messages
40
Reaction score
5
First Language
Italian
Primarily Uses
RMMV
First of all, sorry if I placed this topic on a wrong section. I will spoiler the reason why I posted here
Well... this question is asking about how to write properly a RpgMaker MV plugin which requires an extra config file which stores an information not to be stored in a save game file. This is why I placed here in Javascript/Plugin support.
--------------------------------------------------------------
This is another question related to my project I started one year ago: a translation system that will allow to have multiple language on your RpgMaker game to be loaded on the fly.

I'm doing this job both for RpgMaker VX Ace and RpgMaker MV. In both cases I need an extra file where to store the current active language, loaded independently BEFORE even starting the game (so you can see, for example, translated main menu commands)

On RpgMaker VX Ace (wich can deploy only windows games) I could simply add a text file containing that extra information to be loaded
Code:
language = "language_identifier"

But I higly doubt this could be a nice solution for RpgMaker MV.
Here, infact, I must find a cross-platform solution that could work not only on a "complete" OS (like Windows, Linux and Mac) but also on an embedded device (like iOs and Android) and also on browser games (where informations cannot be stored in the server hosting the game).

So my first question here is: what is the best proper way (cross-platform) to store the "language_identifier" (a string value) which allows me to know what is the current active translation to be used, and which should be loaded at game startup even when there are no active save game?

Thank you for your time.
 

Unqou

Veteran
Veteran
Joined
Mar 28, 2016
Messages
40
Reaction score
5
First Language
Italian
Primarily Uses
RMMV
I will answer myself, even if I cannot say 100% that it is the right answer, but I assume so.
After analizing a bit the core JavaScript files, I decided to use this strategy:

PHP:
    // --------------------------------------------------------
    //  Config (current language)
    // --------------------------------------------------------
   
    Object.defineProperty(ConfigManager, 'utrCurLang', {
        get: function() {
            return UtrTranslator.curlang;
        },
        set: function(value) {
            UtrTranslator.curlang = value;
        },
        configurable: false
    });
   
    var _cm_mkdata = ConfigManager.makeData
    ConfigManager.makeData = function() {
        var config = _cm_mkdata.call(this);
        config.utrCurLang = this.utrCurLang;
        return config;
    };
   
    var _cm_adata = ConfigManager.applyData
    ConfigManager.applyData = function(config) {
        _cm_adata.call(this, config)
        this.utrCurLang = this.readUtrCurLang(config, 'utrCurLang');
    };
   
    ConfigManager.readUtrCurLang = function(config, name) {
        var value = config[name];
        if (value !== undefined) {
            return String(value);
        } else {
            //todo: return default value;
        }
    };

My plugin needs to know what is the current active language (wich is stored in the "curlang" property of my UtrLanguage class).
I decided to save/load this information through ConfigManager instead of using a separated info file.
Since ConfigManager is the standard way to load/save options (for example audio volume) so it should be cross-platform (or I hope so) and It should save options in the right location(s).

The reason why I set "configurable" to "false" is that the information is only managed in my plugin and the final user must never directly change this value (only plugin itself will change and save it when necessary).
I have to mark that the window "Options" does not magically add by itself the "active current language" even if you set "configurable" to true. However I think that setting it to "false" should be a nice idea.

I have only some doubts about how it actually store those data in embedded systems (iOS and Anrdoid) so I can't actually say that my question is solved, and this is why I will not add a [solved] markup to this thread.
 

Latest Threads

Latest Posts

Latest Profile Posts

I managed to fix my car at last... :biggrin:

I'm proud of what I have achieved with my project. Don't mind with the Spanish, Ill add more languages.
Our garage has been so full since moving we haven't been able to get our car in. Storm night before last (no hail), storms forecast for last night & today. I convinced hubby we should clean out the garage and we managed to get it done and get the car in. Hail last night! Just in time!
Taller RTP Characters, Rewrite Dialogues w/ AI, & Simple Event AI & Shooting | RPG Maker News #37

Forum statistics

Threads
111,278
Messages
1,059,847
Members
144,578
Latest member
rodeorodent
Top