From 20d6e91d41b34897eb5facce19e256576d49c4ed Mon Sep 17 00:00:00 2001 From: LmeSzinc Date: Mon, 25 May 2020 23:01:00 +0800 Subject: [PATCH] Doc: How to support other server/language --- doc/development.md | 48 ++++++++++++++++++++++++++++++++++++++++ module/base/decorator.py | 3 ++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/doc/development.md b/doc/development.md index 014e6d7a4..9cce14dd5 100644 --- a/doc/development.md +++ b/doc/development.md @@ -382,3 +382,51 @@ class Config: 未完待续 + + +## 如何支持其他服务器/语言 How to support other server/language + +### GUI + +Copy `./module/config/argparser.py` to `argparser_xx.py` and change the argment. + +Create a dictionary in `./module/config/dictionary.py` that translate your language to english. + +Copy `alas_cn.py` to `alas_xx.py` and import `argparser_xx.py` . Then, edit server name. + +> Format of .pyw file name: _.pyw +> +> Script name is used to load ini file under `./config`, For example, alas_cn.pyw and alas_en.pyw both loads `./config/alas.ini`, but in different languages. + +### Assets + +Copy folder `./assets/cn` to `./assets/`, and replace the image. This will cost a lot of time to find, crop and test. Fortunately, if a image does not contain any charactors, it may works in all servers. + +After replacing an image, don't forget to run `./dev_tools/button_extract.py` + +### Class methods + +Some method may be different in different servers. This decoractor is use to calls different function with a same name according to config (AzurLaneConfig instance). + +``` +from module.base.decorator import Config +from module.base.base import ModuleBase + +class AnotherModule(ModuleBase): + @Config.when(SERVER='en') + def function(self): + # This method will be called only in EN server + pass + + @Config.when(SERVER=None) + def function(self): + # This method will be called in other server + pass +``` + +### Other + +There area also some modules diffcult to change: the commission module. + +In `./module/reward/commission.py`, I use [cnocr](https://github.com/breezedeus/cnocr) to recognize commission name in chinese, it may not works well in other languages. + diff --git a/module/base/decorator.py b/module/base/decorator.py index 5a37b67d4..6b5b73fb1 100644 --- a/module/base/decorator.py +++ b/module/base/decorator.py @@ -54,7 +54,8 @@ class Config: """ for record in cls.func_list[name]: - flag = [self.config.__getattribute__(key) == value for key, value in record['options'].items()] + flag = [value is None or self.config.__getattribute__(key) == value + for key, value in record['options'].items()] if not np.all(flag): continue