mika-n / NGPCarMenu

Custom "Select Car in-game menu" for Richard Burns Rally (RBR v1.02 SSE) game. The plugin supports custom car preview images (the real RBR 3D rendered custom car images), car specs from NGP physics model (engine, transmission, FIA category, year, etc), longer car menu names (up to 30 chars in a menu) and even more chars in the car specs window. New car preview images are created through in-game menu of the plugin.
37 stars 4 forks source link

It only works in English #6

Open RBRPro opened 4 years ago

RBRPro commented 4 years ago

Hi mika and congratulations for your work! I've tested it against my RBRPro and i've found a possible issue. When I change the language of the RBRTM plugin to something different than english the RBRTM plugin is not detected and the integration fails. Also, if I point the language file of RBRTM to some location different than the RBR Plugins folder the RBRTM is not detected. I've given a look at the source code and I think it can be fixed easily. Thanks again!

mika-n commented 4 years ago

Hi. Aah. Right. Good catch. The language other than English is a problem (or other way around, depends on how to look at it). I will fix this issue, so the next upcoming update should have the fix (there are couple other tiny improvements also).

Localization of the NGPCarMenu plugin itself is also in-complete. Couple labels there are fixed to be in English. I should look at that issue also and make it possible for users to localize label values. Fortunately most of the labels are borrowed from the RBR game itself, but there are some labels not found from the vanilla RBR game so those need an additional translation file.

mika-n commented 4 years ago

Investigated this a little further and after all things seem to work OK.

Now I'm not quite sure why it didn't work out there (by the way, my local WinOS language is Finnish, but it should not have anything to do with RBR game and how NGPCarMenu plugin works). Did you have any "special chars" in path or RBRTM language file names (by "special" I mean something else than the usual ASCII western chars)? For example Finnish/Swedish ä/ö/å letters often cause issues in "americano only" apps.

However, I need to fix the localization issue within the NGPCarMenu plugin itself (couple labels were still in English even when the RBR base game was on German custom language).

RBRPro commented 4 years ago

I will try to be more clear my language files are in the Plugins/RBRTM directory. But it seems that when the LanguageFile in RichardBurnsRally.ini points to a whatever file the NGPCarMenu does not detect the RBRTM anymore. If i move or delete the language file so that the path pointed by LanguageFile is invalid, then RBRTM defaults to english and CarMenu is able to detect it.

mika-n commented 4 years ago

Just tested this again and the scenario you described seems to work.

Veeeeery strange that the scenario doesn't work there. What other plugins you use at the same time? Or maybe you could zip and post the RBRTM language file you use? Zip the file and drag-and-drop to a comment field.

RBRPro commented 4 years ago

I've found the issue. In my language files the string 1 in the language files was renamed. If it is not exactly "RBR Tournament" the plugin is not detected. By the way (hopefully with your consent) I am integrating your plugin in my mod. I've read the license agreement and I think that we comply the requirements as non-commercial project. My manager provides a carList automatically to the plugin and also sets the rectangle alone without the need of configuration from the user, the result is very nice. As soon as the integration is ready I will warn you. Thank you very much!

RBRPro commented 4 years ago

image Finished. Just to give a little contribution here is how i am calculating the preview position. Using these formulas you can avoid manual configuration. Not customizable but it works whatever the resolution! My manager knows the screen res then it can configure everything automatically. Another thing. Users don't use always the same resolution. If they change resolution they have to REMAKE all the cars previews and this could be very boring. I suggest you to position the car preview in quick race mode so that it is just centered on the screen. You can take your screenshots at 1920x1080 and then adapt them to whatever resolution.

Thank you very much for the work.

Here is my function, it's C# but very understandable even if you are not familiar with it

void ConfigureCarMenu() { int H = _yres; int W = _xres; int W169 = (H * 16) / 9;

        int X1 = W / 2 - (632 * W169) / 1920;
        int Y1 = H / 2 + (242 * H) / 1080;
        int X2 = W / 2 + (244 * W169) / 1920;
        int Y2 = H / 2 + (490 * H) / 1080;
        int Y3 = H / 2 - (304 * H) / 1080;
        int Y4 = H / 2 + (240 * H) / 1080;
        int X3 = W / 2 - (722 * W169) / 1920;

        IniFile carmenuConfig = new IniFile("Game\\Plugins\\NGPCarmenu.ini");
        string res = $"{W}x{H}";

        carmenuConfig.Write("ScreenshotCropping", $"{0} {Y3} {W} {Y4}", res);
        carmenuConfig.Write("CarSelectLeftBlackBar ", $"{0} {0} {X3} {H}", res);
        carmenuConfig.Write("CarSelectRightBlackBar  ", $"{W-X3} {0} {W} {H}", res);
        carmenuConfig.Write("RBRTM_CarPictureRect", $"{X1} {Y1} {X2} {Y2}", res);

        string previewsDir = $"Game\\Plugins\\NGPCarMenu\\preview\\{res}";

        if (!Directory.Exists(previewsDir))
        {
            CopyDir.CopyFolder($"Game\\Plugins\\NGPCarMenu\\preview\\1920x1080", previewsDir);
        }
    }

you can download RBRPro from here

mika-n commented 4 years ago

Jep. The plugin identifies the RBRTM by the plugin name "RBR Tournament". None of the default localization files of RBRTM had "localized" that string, so never thought of that. I will add a logic to see if richardburnsrally.ini RBRTM setting has a custom localization file and then looking up the "RBR Tournament" string value from there, so the identification process would still work.

Thx for "crop rectangle location" tweaks. I will take a look at this and integrate it into the master version. I will probably make it in a way that if "rectangle entry" is missing or empty then something like this is used to calculate and write out the default value. This way user can still tweak the value if necessary, but a new previously "unknown" resolution has better default value. I knew the current logic to calculate a completely new default value was very bad and a result of "quick and dirty just throw in something" implementation. Never got around to improve it.

The upcoming new version (not yet released) already has improvements in how an existing picture is scaled if the pic doesn't "fit in perfectly" natively. The default logic tries to scale the picture to fit the area while keeping the aspect ratio, but the new version has additional options to let user to set scaling options (scale while keeping aspect ratio vs stretch/shrink to fit the whole area and ignore aspect ratio, position to top or bottom of the rect area if the pic is scaled with aspect ratio and it doesn't "fill" the whole area etc...). This way an existing preview picture in "wrong resolution" would still look good and fits the rectangle area the way user wants to see the pic (some users use "artistic" car pics and not those "live" game screenshots. Artistic pics may look good enough even when it is scaled without keeping the aspect ratio correct).

The new version has also localization support for those labels shown on "car selection" screens in RBR and RBRTM menus. Plus some random bug fixes.

The logic of using "replays" to generate those preview images is not perfect. For example some cars may have a bit weird wheel and camper setup and the result is shown in the pic (unless there is a plugin\ngpcarmenu\replay\ replay file with ngpcarmenu_carModelNameHere.rpl or ngpcarmenu_carCategoryNameHere.rpl file with better wheel setup for a car). In most cases those small errors in wheel positioning are irrelevant for the purpose of the preview pic, but in some cases "expert user" may wonder why wheels look a bit weird. I already have an improvement in a lab to this issue. At some point I will release a new version where those automagical screenshots are generated using a rally stage and not a replay file. This way the wheel setup will be perfect per car and the position of the car in the screen is more predictable.

Feel free to integrate the plugin into your non-commercial mod as long license files or texts from there are included in the delivery package and changes to the plugin code are also released as open-source community contributions (released somewhere, doesn't have to be part of Github pull requests in my site). After all the NGPCarMenu plugin probably would not have seen the light in the first place without other people doing the same earlier, so it was only reasonable I would release the plugin code also as opensource release.

mika-n commented 4 years ago

V1.09 version released and it fixes the issue with localized RBRTM plugin specific language files.

V1.09+ versions support new LanguageFile config option to set a custom localization file for NGPCarMenu plugin itself (no more just English in NGPCarMenu property names in RBR game screens). The NGPCarMenu plugin menu itself is just in English (after all end users don't have visit in this plugin menu very often), but in-game labels (category/year/horsepower/etc labels) now support localization.

V1.09+ version also has new CarPictureScale and RBRTM_CarPictureScale options to tweak how pictures in "non-native" size and resolution are scaled and drawn.