Retera / WarsmashModEngine

An emulation engine to improve Warcraft III modding
GNU Affero General Public License v3.0
255 stars 45 forks source link

HashedGameObject.size() #46

Closed linsmod closed 8 months ago

linsmod commented 1 year ago

Two changes:

1) Support size() in HashedGameObject then we can use it for loop instead of read the user defined "Count" element in ini file. 2) set 'incremental' of FontParameter to true value to support non-ascii characters rendering.

linsmod commented 1 year ago

When the mpq resource has Chinese characters: IF FreeTypeFontParameter.incremental=false (default) image

IF FreeTypeFontParameter.incremental=true image

it's about that the FreeTypeFontParameter does not contains any extra characters except asccii codes when generateFont(). after enabling incremental, it will do auto search in FreeTypeBitmapFontData. then non-asccii codes can be rendered.

Retera commented 1 year ago

Parameter.incremental seems like a really solid change but the fields.size() value feels weird to me and I wish we could solve that problem in a way that was more mathematically accurate and on-point. The field size there is not the same as the old count value, but happens to always be larger. So in a roundabout way it will work. But it makes the code more difficult to follow. Is there some way that we could get the size value you want, and not an arbitrary number that happens to be greater than or equal to the size value you want?

Edit: as an example, what if it did this?

[DataSources]
00=MPQ,"/home/etheller/Applications/MiniWc3/war3.mpq"
01=MPQ,"/home/etheller/Applications/MiniWc3/war3x.mpq"
02=MPQ,"/home/etheller/Applications/MiniWc3/war3xlocal.mpq"
03=MPQ,"/home/etheller/Applications/MiniWc3/war3patch.mpq"
04=Folder,"../../resources"
05=Folder,"."

By formatting it like this, hashGameObject.size() becomes a correct loop value instead of looping "too much but it happens to be OK." Then you could also remove the case "":

linsmod commented 1 year ago

If applied this change, we can use the new key:value or key:value,value,value style.

See the bottom of the dataSources section, it starts at the kvStyle.

image

image

image

the code changes in parseDataSources not included in this pull request.

changes are from a fork of warshmash. ,It is the part of my work to porting it to android. There was too much broken changes on the fork and I picked this one or two. wish someday warsmash have a universe version can build once the run both desktop and android.

And yes, it's a not a necessary change for warshmash currently. ignore this would be fine.

About the Parameter.incremental, it is a one-line change. just copy and paste and no thanks ^^