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

Unqou

Veteran
Veteran
Joined
Mar 28, 2016
Messages
37
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
37
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

https://s12.directupload.net/images/200715/34vwhkoz.png Finally have a concept I am happy with, now I just have to decide wheather I really want to do it as vector art.
I just keep coming up with weird ideas, and then spend the time trying to make sense out of it.:kaocry:
Hi, Erm... My name is zozobie! I just had a snack.
Face masks are to be compulsory when inside shops in England from the 24th of July. People can be fined £100 if they fail to comply.

Forum statistics

Threads
99,691
Messages
968,062
Members
131,380
Latest member
3dprintindex
Top