Author Topic: MOD: UI convenience / bug fixes  (Read 3502 times)

Offline AdamMil

  • Newbie
  • *
  • Posts: 9
MOD: UI convenience / bug fixes
« on: August 09, 2014, 04:10:51 PM »
The devs have said that they have only a couple hours per week to work on community-requested features. Because of that, a day or two ago I decided to create a mod to implement some requested features from the Mantis bug tracker. I started by implementing the features that I personally requested, but I think some of these will be useful for everyone. I also did a bit of bug-fixing.
  • #15634: structure (e.g. turret) templates
  • #15635: shift-select a subset of the selected units
  • #15636: right-clicking enemy ships in the planet overview/summary should attack them
  • #15637: clicking an enemy or ally in the planet overview/summary deselects your ships
  • #15638: planet-specific auto build engineers (etc) builds the wrong number
  • #15639: show warnings / alerts in the galaxy view
  • #15690: Bottom-aligned context menus overlap the global unit selection buttons
  • #3836: Allow auto-build sliders in CTRLS to work without having tech
Here are the details.

#15634: structure (e.g. turret) templates
This feature lets you save templates for groups of structures that you frequently construct. For instance, if you have a standard layout of turrets that you place around wormholes or in a system, you can save the group as a template and easily build more copies of it. The templates are global, so you can share them between campaigns. Here's how it works. First, select the items you want to save as a template. The items have to be the kind that can be directly constructed, but they don't actually have to be "buildings". (They could be directly constructable ships if you wanted.) Then alt-right-click to open the context menu and choose to save the template. I implemented a system with a fixed number of template slots for simplicity.


Later, when you want to build the template, deselect everything and alt-right-click again to open the context menu. Choose the template you want to load.


Move the ghost where you want it. (If you're building very close to a wormhole, you may have to be precise in your positioning.)


Click to place the template. Time saved! This is great in multiplayer when you don't want to annoy everyone by pausing the game to get some defenses up. It also works with a mobile builder when you want to quickly set up a beachhead in enemy territory.


Note that if building the template would exceed the cap for a particular type of object, the error message displayed might not show the correct object name.


#15635: shift-select a subset of the selected units
This feature lets you easily select a subset of the selected units. For instance, if you have a large blob selected, you can easily select just the ships you want. Here's how it works. First, have some ships selected. Then, hold down shift and click on each of the ships you want in the list. They'll turn yellow to show that they're part of the pending selection. (Shift-alt-click, shift-ctrl-click, and shift-alt-ctrl-click should work as expected: Shift-click again or shift-alt-click to remove the ship from the pending selection. Shift-ctrl-click to add a whole class of ships to the selection. Shift-ctrl-click again or shift-alt-ctrl-click to remove a whole class of ships from the selection.)


Finally, release the shift key to make that the new selection!



#15636: right-clicking enemy ships in the planet overview/summary should attack them
#15637: clicking an enemy or ally in the planet overview/summary deselects your ships
These two features, together, make it a bit easier to control your ships in a battle. First, if you have ships selected, you can right-click an enemy icon to attack a ship of that type. Right-clicking again attacks the next enemy of that type. This works with shift-attacking too. For instance, if you want to make a quick raid on the enemy's tachyon guardians, and you see in the planet overview/summary that they have four of them, you can simply shift-right-click the tachyon guardian icon four times to quickly add all of them to the attack queue. You should also be able to right-click an icon for an allied ship to move your selected units to the allied ship (although I haven't tested it). The second feature makes the game not deselect your units if you click on icons for enemies or allies. Instead it just moves the camera. So if you move the camera to an enemy, you can immediately attack without having to reselect your ships. Alternately, you can jump to an ally to see how they're doing without losing control of your own ships.

#15638: planet-specific auto build engineers (etc) builds the wrong number
This feature allows the per-planet auto-build settings to override the global settings. Normally, the per-planet settings are added to the global settings, so if your global settings say to auto-build two Mk I engineers and your per-planet settings say to build one Mk I engineer, the planet will end up building three of them. It's impossible to have per-planet settings build fewer units than the global settings. The mod fixes that by making per-planet settings override the global settings, so in the previous example, only one engineer would be built rather than three. The mod also allows you to specify that no engineers should be built. That is, rather than having zero mean "use the global settings", it uses -1 for that, so you can specify a per-planet value of zero in order to disable auto-building on a specific planet.


Note that if you apply the mod to an existing campaign, you may need to adjust your auto-build settings because they'll start building different numbers of items, and because most planets will specify zero for the auto-building. If you start a new campaign, no adjustment should be needed.


#15639: show warnings / alerts in the galaxy view
I tend to spend a lot of time in the galaxy view to get an overview of everything that's happening, but the game hides alerts, messages, and your selection while in that view. Because of that, I've lost many planets due to being unable to see the "200 enemy ships on ImportantPlanet" etc. alerts. So I've made all that stuff visible on the galaxy view, although I tried to hide unimportant messages. Having the selection visible is also nice so you can monitor the progress of a battle (or some repair work) while remaining in the galaxy view, and instantly retreat your ships if they get too damaged.


If you want to hide them temporarily, perhaps because they're obscuring a planet, you can press the Ctrl key.

#15690: Bottom-aligned context menus overlap the global unit selection buttons
This bug causes certain context menus to overlap other buttons in the UI. That wouldn't be a problem except that the game fails to consider Z-order when processing button clicks, so if a context menu overlaps the buttons along the bottom of the game window you won't be able to click the last few items in the context menu because they'll activate the buttons instead. I didn't fix the click processing in general but I fixed the problem that caused the menu to overlap the buttons in the first place. I'm a big user of assault transports and being unable to choose some of the items from the special unload menu was a frequent annoyance for me.

#3836: Allow auto-build sliders in CTRLS to work without having tech
This issue prevents you from moving the auto-build sliders for Mk II and Mk III engineers if you don't have the tech yet. If you save the CTRLS to disk when you have the tech and then load it in a new campaign, you can end up with Mk2/3 sliders set to build several per planet and no way to disable them (because you can't adjust the sliders). Then, when you unlock the tech, they instantly get built everywhere even when you didn't want that. So I made it possible to move the sliders before you have the tech. Of course it doesn't actually auto-build them until you get it.

Other Notes
I haven't done extensive testing, especially in multiplayer, although I've played with the mod for about 20 hours in single player. I've only tested it in Windows, but I expect that it'll work on other operating systems. Let me know if you have any problems! Be aware that new game updates will overwrite the mod and you'll have to install it again. I do hope the developers include these features in the game because creating this mod was painful and maintaining it will be a chore. To the devs: I'd be happy to work together on getting some of these features into the base game!

Download and Installation
The mod can be downloaded from http://www.adammil.net/blog/v123_AI_War_UI_Mod.html. Installation instructions are there as well.
« Last Edit: August 21, 2014, 05:23:35 PM by AdamMil »

Offline TechSY730

  • Core Member Mark V
  • *****
  • Posts: 4,552
Re: MOD: UI convenience
« Reply #1 on: August 09, 2014, 04:49:04 PM »
On one hand, its awesome someone has been putting time into messing with game logic at this "deep" level. Something I played around with earlier, but was shy about really doing much due to EULA issues. (See below)

On the other hand, this doesn't seem practical to keep up with patches. Thanks to the somewhat monolithic nature of the code and data, everything would need to be reapplied after every update, which is in many cases, extremely frequent in the "Arcen world". Also, it could very easily come to a place where the patch won't work anymore if the code bass changes too much.

Also, there is multiplayer sync issues. The network model is, quite frankly, rather " brittle", it doesn't take much difference between the clients and the server to cause big desyncs.

Also, there is the potential EULA issues about dissasembly and modifying game files. I would need to reread it in detail to be sure about this. I think Chris (x4000) has stated he won't like personally go after a person for doing this (EDIT: but I am not an authoritative source on this), but it would still be rude to just violate EULAs without additional explicit permission from the devs.

You probably want to ask Chris (the lead dev and founder of Arcen) if it is OK to publish this sort of stuff just to be sure.
« Last Edit: August 09, 2014, 04:52:40 PM by TechSY730 »

Offline AdamMil

  • Newbie
  • *
  • Posts: 9
Re: MOD: UI convenience
« Reply #2 on: August 09, 2014, 05:05:39 PM »
Hey, thanks for the reply.

Quote from: TechSY730
this doesn't seem practical to keep up with patches... everything would need to be reapplied after every update, which is in many cases, extremely frequent in the "Arcen world". Also, it could very easily come to a place where the patch won't work anymore if the code bass changes too much.
That's all true, which is why I'm hoping that some of these can be included in the base game (especially construction templates and shift-selection, which are good time-savers and shouldn't be controversial). Since they don't have much time for community-requested features, I thought I'd help by doing most of the implementation work. :-P  In any case, I'll maintain the mod as long as I'm actively playing the game.

Quote from: TechSY730
Also, there is multiplayer sync issues. The network model is, quite frankly, rather " brittle", it doesn't take much difference between the clients and the server to cause big desyncs.
That is an important issue, but I did think about it and I don't believe these changes will cause any multiplayer sync problems. It should be fine if some people have the mod and others don't. (That said, I don't have anyone to test it with.)

Quote from: TechSY730
Also, there is the potential EULA issues about dissasembly and modifying game files.
Well, I was careful not to violate any agreements that I've made.

Quote from: TechSY730
You probably want to ask Chris (the lead dev and founder of Arcen) if it is OK to publish this sort of stuff
I thought it might be pretentious to interrupt him with a personal email or something. I figured he could respond on the forums if he wanted to...

Anyway, I just want to make the game better. :-)
« Last Edit: August 09, 2014, 05:41:30 PM by AdamMil »

Offline Aklyon

  • Core Member
  • *****
  • Posts: 2,089
Re: MOD: UI convenience
« Reply #3 on: August 09, 2014, 05:18:52 PM »
This sounds like it would be rather relevant to here.

Offline keith.lamothe

  • Arcen Games Staff
  • Administrator
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,504
Re: MOD: UI convenience
« Reply #4 on: August 09, 2014, 06:00:50 PM »
I can't speak for Chris on how he feels about this sort of thing, but other than that:

Wow :)  Out of curiosity, did you do this by decompiling the Assembly-CSharp.dll, changing the source, and recompiling?  I mean, I hope you didn't have to resort to hex editing or whatnot.

Also I hope you used the existing construction template stuff from the 3.189 era rather than re-implementing it yourself.  Iirc I discontinued that feature during the unity port due to some serialization issues (not specific to unity, it just hadn't been working properly at all and we hadn't noticed til then) and didn't get around to re-implementing it because often placing turrets and such is more case-by-case than that really allows.

Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline AdamMil

  • Newbie
  • *
  • Posts: 9
Re: MOD: UI convenience
« Reply #5 on: August 09, 2014, 06:47:45 PM »
Quote from: keith.lamothe
Wow :)  Out of curiosity, did you do this by decompiling the Assembly-CSharp.dll, changing the source, and recompiling?
No. As far as I know, there's no decompiler available that's capable of correctly decompiling a large project like AI War. (Usually, if it decompiles at all, it'll have hundreds or thousands of errors, most of which prevent recompilation, but many of which just silently break the program or introduce nasty bugs.)

Quote from: keith.lamothe
I mean, I hope you didn't have to resort to hex editing or whatnot.
I only did a little bit of hex editing. :-P  Mostly I used the disassembly. But, for instance, "foreach(var obj in list) { }" is just one line in C#, but about a whole page of nasty code after being disassembled. It's extremely verbose, and you lose all the variable names, etc. The result was well over a million lines IIRC, all in one file, so it was quite painful to deal with, especially with my text editor crapping out every 40-60 seconds.

Quote from: keith.lamothe
Also I hope you used the existing construction template stuff from the 3.189 era rather than re-implementing it yourself.
Yes. I was happy to find that. :-)  It didn't work at first. Various pieces of code assume that all of the objects have the same type. (I.e., it only looks at UnitPlacements[0].RightItem or whatever and assumes all the other placements are the same.) But I mostly fixed that.

Quote from: keith.lamothe
Iirc I discontinued that feature during the unity port due to some serialization issues
Hmm. I didn't fix any serialization issues. Hopefully they won't affect the way I'm using them. (I'm not sending the data over the network, for instance. I'm just using them locally to "script" a sequence of object placements.)

Quote from: keith.lamothe
didn't get around to re-implementing it because often placing turrets and such is more case-by-case than that really allows.
Well, maybe it's just me, but I have a very standardized turret placement scheme that uses every kind of turret in a pattern to combine all the different attack bonuses, plus a ring of mines. I only deviate from the pattern in special cases. It's a tremendous pain to do manually for every single wormhole, and stressful in multiplayer when I can't pause the game. :-P
« Last Edit: August 09, 2014, 07:02:12 PM by AdamMil »

Offline keith.lamothe

  • Arcen Games Staff
  • Administrator
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,504
Re: MOD: UI convenience
« Reply #6 on: August 09, 2014, 07:02:42 PM »
Ah, ok.  Sorry it came to hex editing, though I guess you found it at least somewhat fun or you wouldn't have done it :)

On reflection, there is one significant caveat I'd like folks to keep in mind with this sort of thing: if you "mod" the dll like this, please don't submit bugs that you can't reproduce in an unmodded version of the game.  The kinds of changes involved even in this "mod" create a kind of "all bets are off" situation as far as proper execution of the program.  Especially in multiplayer but even in singleplayer.

So ultimately the solution to getting these things in the game is still having us implement the stuff. 


Honestly the AIW codebase (and that of our other games) is a bit like a lumber mill which consists of
- four walls
- an axle suspended between two of those walls about 6 feet above the ground
- a massive diesel engine that turns that axle very fast
- several 10-foot-diameter circular saw blades mounted along that axle
- several trucks that cart in raw trees and use a sort of crossbow device to fire them into the blades

The result is still cut lumber, cut with preternatural evenness, but there are close to zero safeguards against utter catastrophe.

So someone coming in to make modifications to this setup, even with ideal tools... well, it can work, or it can be very bloody :)


All that said I am happy to re-implement construction templates post-8.0 once I've got the basics of a new UI (which incorporates the context menu into the rest of the UI, etc) in place, and I may benefit from the notes of what's been done here.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline Cinth

  • Core Member Mark II
  • *****
  • Posts: 2,527
  • Resident Zombie
Re: MOD: UI convenience
« Reply #7 on: August 09, 2014, 07:07:55 PM »
I thought it might be pretentious to interrupt him with a personal email or something. I figured he could respond on the forums if he wanted to...

I would just send a PM though the forums here.  Both Chris (x4000) and Keith are pretty open to communication (personal experience talking here). 
Quote from: keith.lamothe
Opened your save. My computer wept. Switched to the ST planet and ship icons filled my screen, so I zoomed out. Game told me that it _was_ totally zoomed out. You could seriously walk from one end of the inner grav well to the other without getting your feet cold.

Offline AdamMil

  • Newbie
  • *
  • Posts: 9
Re: MOD: UI convenience
« Reply #8 on: August 09, 2014, 07:18:32 PM »
Quote from: keith.lamothe
Sorry it came to hex editing, though I guess you found it at least somewhat fun
Nothing to be sorry about. :-)  It wasn't exactly fun, but it makes AI War more fun (for me), so it was worth it.
Quote from: keith.lamothe
Honestly the AIW codebase ... is a bit like a lumber mill
That's the most interesting description of a codebase I've heard yet. :-)
Quote from: keith.lamothe
All that said I am happy to re-implement construction templates post-8.0
At the rate of 0.001 version number increments per day, I guess that'll be about 2.6 years from now. ;-)  But I'm looking forward to it!

Maybe you should get another programmer. I am willing to work for free. :-P
« Last Edit: August 09, 2014, 07:34:52 PM by AdamMil »

Offline keith.lamothe

  • Arcen Games Staff
  • Administrator
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,504
Re: MOD: UI convenience
« Reply #9 on: August 09, 2014, 07:39:40 PM »
At the rate of 0.001 version number increments per day, I guess that'll be about 2.6 years from now. ;-)  But I'm looking forward to it!
7.0 to 8.0 has been less than a year and a half :)  And that was one of the longer cycles.


Quote
Maybe you should get another programmer. I am willing to work for free. :-P
I appreciate the offer, but with a buzzsaw-safety-margin codebase like this the costs of having more than one person making active changes, or having anyone making active changes who isn't intimately familiar with how things were done... well, it'd take a long time before the overall output was higher than before.

But I'm happy to consider "if you change X it lets us do Y" feedback.
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline AdamMil

  • Newbie
  • *
  • Posts: 9
Re: MOD: UI convenience
« Reply #10 on: August 20, 2014, 06:31:08 PM »
I added a fix for bug #15690 (bottom-aligned context menus overlap the global unit selection buttons).

Offline AdamMil

  • Newbie
  • *
  • Posts: 9
Re: MOD: UI convenience / bug fixes
« Reply #11 on: August 21, 2014, 05:20:13 PM »
I added a fix for #3836 (allow auto-build sliders in CTRLS to work without having tech).