Author Topic: Why are my % and other figures broken?!?! (If this is you. Please read)  (Read 8881 times)

0 Members and 1 Guest are viewing this topic.

Offline smoelf

  • Commander
  • *********
  • Posts: 337
  • Thanked: 142 times
  • 2021 Supporter 2021 Supporter : Donate for 2021
As for the numpad: I have myself a , for it printed on my current physical keyboard on the numpad, but I use an English (US) keyboard layout (and others at other times), so the numpad works fine.  If you do not need various keyboard layouts otherwise and don't want to switch the whole layout because other keys will then not do what they say on the label, it should be possible with very simple tools to create your own custom keyboard layout.  I myself use two adapted for special tasks with a bunch of additional signs stuffed in.  But for this, you can create one with just one or two keys changed from default, in this case just exchange comma with period, so that the numpad works for decimals.  You can then use that custom layout in Windows while running Aurora by selecting it in the language bar (I'm not sure if it's displayed by default these days, but it's easy to find) in the taskbar just like any standard keyboard layout or add a shortcut for switching.

If you want to try it and can't find on your own, I could look up which tool I used, and if it still exists, give you a link.  It may even be part of Windows, not sure.  It really takes only a minute.  Setup once, forget, use.  My main one must be more than a decade old and has already been ported across Windows versions.  It might only annoy you to have the language bar displayed permanently if you have no other use for it.  But as long as you don't forget to switch back when you need to: it should be possible to setup a shortcut without it, I think.

That's an excellent idea. Certainly a lot faster to change a saved keyboard layout than switching the area settings every time. Thanks :)
 

Offline Second Foundationer

  • Warrant Officer, Class 1
  • *****
  • Posts: 94
  • Thanked: 34 times
A pleasure if it is of any help.

Only to make sure, a general note for all comma-separated problems: Changing the keyboard layout does NOT in itself change your operating system's number format.  For that, please refer to the first post in this thread.
 

Offline Tree

  • Sub-Lieutenant
  • ******
  • Posts: 143
  • Thanked: 27 times
If you are running Windows 10 and would like to keep your own regional settings for everything else other than Aurora, the following approach works:

1) Create a new local user (settings) be sure and give it a password
2) Log out and then Log in as the new local user, follow the instructions in the previous post above to change settings.
3) Log out of the new local user and Log back in as your normal user.

For then on, when you want to start Aurora, control+shift+right-click on the Aurora.exe file, select 'run as different user', enter the name and password for the new local user you created.  This runs Aurora with the regional settings it needs and leaves the rest of your programs (and desktop) as you like (had set previously).

You can also create a .bat file for it so you can skip the ctrl+shift+right click and just double click as normal. Put this line in notepad:
runas /profile /env /savecred /user:computername\username "C:\Games\Aurora\Aurora.exe"
You'll have to replace computername and username with what fits your computer and new Aurora user, the .exe's path, save as a .bat file and now you can run Aurora off the .bat file. It'll only ask for the password once, too.
 
The following users thanked this post: WebGremlin

Offline Destragon

  • Lieutenant
  • *******
  • D
  • Posts: 151
  • Thanked: 87 times
AuroraMod has a setting that lets you customise the number culture and date format, without having to change them in your system or having to create a new windows profile:

Edit: Fixed the link
http://aurora2.pentarch.org/index.php?topic=11382.0

Edit 2:
For Auora version 1.13 (and 2.0), the latest mod to change these settings is this one:
http://aurora2.pentarch.org/index.php?topic=12565.0
« Last Edit: August 12, 2022, 04:53:17 PM by Destragon »
 

Offline SpikeTheHobbitMage

  • Bug Moderators
  • Commodore
  • ***
  • S
  • Posts: 670
  • Thanked: 159 times
Aurora sees the number 100,00 as ten thousand, not 100. Simple as that.

Well, I think it is more that the comma throws off the SQL statements.
C# uses prepared statements so that shouldn't be a problem like it was in VB, since there are no text conversions involved any more.  At this point it should be restricted to reading and writing UI elements and that can safely be done using the user's locale.  It should now just be a matter of making certain that all code touching a given control agrees on what it is doing, which is admittedly a sizable chunk of code.
 

Offline hephep

  • Able Ordinary Rate
  • h
  • Posts: 4
Re: Why are my % and other figures broken?!?!
« Reply #20 on: September 29, 2020, 06:48:10 AM »
I don't know what the internals of Aurora look like, but all inputs should be sanitised anyway as best practice (or standard practice for web dev) - when devs don't do this you end up with security holes; less of a problem with a game, but still.         

You just need two core functions:

string number_format(dynamic in_num) - takes in any type and outputs it as a formatted string using the system preferences.          For bonus points parameters for number of decimals etc.         

float/int parse_number(string in_str) - takes in a string and tries to parse it into a float/int as appropriate.       

C# has a bunch of functions to help with this:
https://docs.      microsoft.      com/en-us/dotnet/api/system.      globalization?view=netcore-3.      1

All user-inputted numbers should use parse_number before being used internally, and everything that's a number should go through number_format before being printed.       I suspect its on these where Aurora currently fails.     

Throw in some unit tests for both functions and you've got some rock solid code that can handle number input/output, and a swath of bug reports just disappears.