ogame-infinity / web-extension

Repository for the web extension code (coming)
https://ogameinfinity.com
Other
34 stars 45 forks source link

The options are extracted from the main init #295

Closed SergioFloresG closed 9 months ago

SergioFloresG commented 9 months ago

The options (OGInfinity.json.options) are extracted from the main build and declared in ./ctxpage/conf-options.js.

The new implementation allows to get the configuration from different parts without the need to transport the OGInfinity instance.

In this implementation there are three exposed functions.

/// file: src/ctxpage/conf-options.js

/** Gets all declared options.  */
getOptions() : ProxyOptions;

/** Gets the value of an existing option */
getOption(name: string) : any | undefined;

/* Allows to set the value of a previously existing or non-existing option. */
setOption(name: string, value: any) : void;

In the case of getOptions() the proxy used prevents new options from being declared directly. If you need to add a new option it is recommended to add it directly in the _options constant.

To avoid future conflicts it is recommended to use native values and avoid nesting objects.

Bishop341-B commented 9 months ago

Nice.

Some things things i think we should change/comment:

* @property {number} limitCargo 1 to 100 what does mean "1 to 100" here? means that value 1 is for 100%?

* @property {boolean} standardFleetId standardFleetId is a number, not a boolean

activitytimers: 0, activitytimers is a boolean, and defaults to false

planetIcons: false, that config option seems to be not used anymore, so we can rid off it

disableautofetchempire should be !autofetchempire not only the default, but in every moment. but even better, i think that as ogi works with autofetchempire values then we can simplify and use that directly as a option property, changing the affected code in settings and removing disableautofetchempire property

rvalLimit: undefined this was originally 4e5 * this.json.speed, we should provide one default, maybe 1e6?

SergioFloresG commented 9 months ago
* @property {number} limitCargo 1 to 100 what does mean "1 to 100" here? means that value 1 is for 100%?

It is a percentage value from 1 (default) to 100 (maximum).

* @property {boolean} standardFleetId standardFleetId is a number, not a boolean
activitytimers: 0, activitytimers is a boolean, and defaults to false

Corrected.

planetIcons: false, that config option seems to be not used anymore, so we can rid off it

Confirms that it is not used and deletes it.

disableautofetchempire should be !autofetchempire not only the default, but in every moment. but even better, i think that as ogi works with autofetchempire values then we can simplify and use that directly as a option property, changing the affected code in settings and removing disableautofetchempire property

I didn't understand how you want to configure this one.

rvalLimit: undefined this was originally 4e5 * this.json.speed, we should provide one default, maybe 1e6?

From the way I see it in the flow, I see a dependence on knowing what the velocity of the universe is. I check which one is being used and confirm if it is possible to extract this value.

commit: efde8d31eb37e59d370be254a129950425284563

Bishop341-B commented 9 months ago

oh... sh*t... i edited your message instead of make a reply... my bad, sorry

trying to fix it XD


* @property {number} limitCargo 1 to 100 what does mean "1 to 100" here? means that value 1 is for 100%?

It is a percentage value from 1 (default) to 100 (maximum).

The value is displayed in settings dialog as a %, but it is stored and used a number (float) where 1 = 100%. The range for the value is 0.01 to 5 (1 - 500 %), the default is 1 (100%)

disableautofetchempire should be !autofetchempire not only the default, but in every moment. but even better, i think that as ogi works with autofetchempire values then we can simplify and use that directly as a option property, changing the affected code in settings and removing disableautofetchempire property

I didn't understand how you want to configure this one.

i will post later the changes ;)

rvalLimit: undefined this was originally 4e5 * this.json.speed, we should provide one default, maybe 1e6?

From the way I see it in the flow, I see a dependence on knowing what the velocity of the universe is. I check which one is >being used and confirm if it is possible to extract this value.

yes, i saw that and this is why i was proposing a fixed multipurpose value that do not depends on the universe speed, so then we do not have to worry about that

Bishop341-B commented 9 months ago

commit done with the changes

disableautofetchempire value should be always !autofetchempire and because OGI only look at autofetchempire value to work we can simplify and use directly autofetchempire in the UI code that manage the "Disable autofetch empire" setting, with a few little changes. thus we do not need anymore and can remove disableautofetchempire property