JanWichelmann / AoETechTree

A new modding-friendly tech tree implementation for Age of Empires II, replacing the old ingame tech tree.
MIT License
11 stars 2 forks source link

Add small empty space between buildings like in the vanilla AoC techtree #2

Open withmorten opened 7 years ago

withmorten commented 7 years ago

See difference here, AoC vanilla first, then your techtree implementation:

http://i.imgur.com/yUskww4.png

http://i.imgur.com/xpz7LXK.png

Seems like every building has a left border of some pixels - it's probably a simple fix if you know where to look in the code, but I haven't really understood how the whole thing works yet.

JanWichelmann commented 7 years ago

Unfortunately that is not as easy as it may seem - the positioning algorithm considers the tech tree window as a large grid, consisting of 2*_ageCount lines, and columns for each half position (see the following example). illustration

As you see, all elements have the same spacing. This allows to write a very efficient mouse hovering algorithm, as I can nearly directly calculate the element grid coordinates from the mouse position. Also it is much easier to have multiple buildings gathered below one parent building (as is the case with the barracks). Adding a spacing between them is rather non-trivial and probably requires a completely different approach. Unfortunately I don't have much time currently, but if you have an idea how to implement it, feel free to do a fork and create a pull request :-)

withmorten commented 7 years ago

Ah, I see. Well, that's a shame - I think the small extra padding is really helpful for distinguishing which unit belongs to which building.

I'll let you know if I have an idea!

Oh, a friend of mine an me also have a (imo) more elegant way of injecting into the game. Rather than having a launcher (or patching the executable), we have a ddraw.dll in the same directory as the age2_x1.exe that passes all ddraw stuff onto the actual ddraw, and at the same time loads all "dlh"s in a "mods" directory. We did some stuff like loading all drs files from a specific dir first (for graphics mods outside of voobly) or adding the AoK menu back into AoC since we liked the buttons more :-)

With a minimal change to the DllMain (by adding the two calls in the Init() to it) your TechTree.dll also worked perfectly. If you're interested, I can send you the MSVC Project etc, it's not up on github anywhere (yet).

pulkit24 commented 7 years ago

+1 How about allowing the user to add a "blank" node where they want that padding? This could take up one grid column and work with your grid format. It would be a larger gap than AoC, but atleast a workable solution. Does creating a unit node with ID -1 work this way? Need to test.

JanWichelmann commented 7 years ago

@withmorten Ah, that's a nice idea! It would be great if you could put your code into a git repository - I will then add it to the installer as an additional installation option. This should solve a lot of problems regarding conflicting mods that modify the EXE directly :-)

@pulkit24 :+1: This is an easy workaround, good idea! I will see that I modify the editor and the view so they will support blank nodes. Thank you!

withmorten commented 7 years ago

Since I don't have time to put it on github right now, here's a zip with the sln and a compiled ddraw.dll:

http://morten.with.de/aoe2/hackloader.zip

Needs to be in the same directory as the age2_x1.exe. We chose the .dlh extension to differentiate it from "normal" dlls.

Your TechTree.dll would need to go into "Age of Empires II\Mods" as TechTree.dlh, and this is my modified TechTree.cpp:

http://morten.with.de/aoe2/TechTree.cpp

Not really fork-worthy either, so I just put it up there. I put the Install's into the DllMain with a check if "Mods\TechTree.dlh" exists. Haven't checked you're actually linking against Shlwapi.lib and include Shlwapi.h ...

I also added a small check if you're actually injecting into Conquerors which my friend and I have been using for our dlh's since it's annoying when you do start up empires2 to check something and everything breaks :-P

I'll put the hackloader and the other dlh's we have up on github soon, just working on some stuff in there still :-)

JanWichelmann commented 7 years ago

Thank you! I will have a look into it as soon as I have time, may take a few days :-)

On first sight I would suggest to stick to the UserPatch's mod file structure, storing the DLLs in a "Age of Empires II\Games[mod name]\Dll" subfolder. This way the age2_x1 directory stays as clean as possible and mods won't interfere.

I would also recommend to leave the Init() function as it is and not use the DllMain - though it will just work in most cases, Microsoft explicitly advises against it. Forcing the use of a separate initialization function should not take much more effort and may prevent some surprises later ;-)

withmorten commented 7 years ago

Ah yes, I'll change it up so loads the Init() function of any Dlh.

Hm, I don't like making these dlhs "Game" specific by having to put them into Games\age2_x1, Games\age2_x2 ... most of these are relevant to any. Maybe just a check if the Commandline includes age2_x1.exe / age2_x2.exe (although who uses that, to be honest, it's a 1byte diffed UP 1.3 with a different icon) would be better.

Do you have anywhere else we can chat? I'm German as well and we're definitely going off topic here ... I'm using Discord for example, if you're on there, but I'm also still on good old ICQ :-P