Eunomiac's Strategy Layer

Good job EF! This does indeed look like fun stuff. Here is an example of the other kind of overlay, the one the game uses to show settlers and naval blockades. It uses CyEngine.fillAreaBorderPlotAlt(). I don't see that one in the Python API (even in EF's updated one) but I found it in the worldbuilder code for both the brush cursor and reveal plot mode. Here is the results of a quick test (Images link to full-size):

Well this thread got me intrigued and in the mood to do some coding, 3 sleepless days later heres what's come out so far...



Each color is on its own layer so they don't blend together unless you use the same color.

Still need to make it save between sessions and figure out some way to actually call it up besides the console.

Also has some wierd issues where it'll stop working if you bring up the WB or move around the screen different ways. I think its because the engine reloads the interface on exit from the WB and it doesn't get reloaded.

Anyway, thoughts comments?
Civ4 gui events are "interesting", trying where the hell a certain screen actually gets its input is like trying to find a needle in a haystack sometimes.

Anyway, what do ya think?
 
Looks like a great start! I'm sure we could help you get the saving and events to work. Saving is fairly straight-forward: you use SdToolkit to store items in (I'm assuming you're fairly advanced coding-wise) a set of Python dictionaries.

How many layers are there again? It's been a while since I looked into this, and I didn't take any notes. :(
 
Wow. I usually don't post much anymore, but this pulled me in. Very nice Del69! I'm sure we can find a way to fix those few quirks you're talking about, but that's awesome! No more having to do dotmapping on screenshots for SGs!:goodjob:

Is there a code snippet for this? Or do you have a modified MainInterface file for it?
 
Forgot to attach the code in the ss post, done off of unaltered BTS, probably work on putting it in as a BUG mod tommorow or the next day.

To Open up the screen do
Code:
from CvOverlayScreenUtils import *
showOverlayScreen()

at the python console ingame with the mod running

Lot of messy hardcoded stuff that needs to be changed around, first mod so I figured it would be easier to get it semi-running then figure out how to do it properly :D

Quick question on screens too, is the way that the original python files from Civ4 suggest (create a custom CvScreenUtils class and have CvScreenUtilsInterface return it from its getScreenUtils() function) still the "right" way of doing screens is there a better method?
 

Attachments

  • Strategy Overlay.zip
    36.9 KB · Views: 86
Very cool. I'm taking a look now. When you put it into BUG, don't forget to check out the docs for modders on our wiki. It will give you the skinny on using the BUG Core, events, options and initialization.
 
I removed my existing CustomAssets folder, renamed your Assets to CustomAssets, and copied it and the INI to my BTS folder. When I do the import and call the function, the interface appears and seems to work (can click colors and the two buttons, and I see the debug messages) except when I add a city nothing shows up. I get a slew of debug calls about leftmousedown call occurring, but no overlay on the map.

Am I missing something?

BTW, check out the Civ4 Python API as well. Quite handy.
 
Still trying to figure out what causes that, sometimes it works sometimes it does nothing and I'm still not sure why.

Try this screen file if nothing else I took out the spammy debug call, forgot about that one.

I think it might have something to do with the place/remove variables not setting right and being false when it should be true or vice versa.

Edit: Well i found out how to make it work, why this works i don't know.

Alt-Tabbing out of the game and changing a file (add a blank line at the top of one) then saving it which makes the game to reload the python modules and suddenly it works?
 

Attachments

  • CvOverlayScreen.zip
    4 KB · Views: 117
Bug fixed, apparently having a global referencing CyEngine() causes it to not be valid at times. I knew there was a reason for that isValid() function....:mischief:

Is there a code snippet for this? Or do you have a modified MainInterface file for it?

Actually haven't touched the MainInterface yet, its its own custom screen that works kinda like the worldbuilder. When its up it intercepts the mouseover and click events on the main screen to do its stuff. But if neither of the buttons to place/remove a city is selected it still passes functionality down to the main ui. So you can still scroll the screen etc.

EmperorFool said:
How many layers are there again? It's been a while since I looked into this, and I didn't take any notes.

For the dots there is only like 2 or 3 layers, uses the same ones as the numpad help and the suggested moves. But really those don't cause a problem, it just redraws all the dots you didn't erase when you erase one since the clear functions clear the entire layer.

The area layers I just started putting down colors and it kept working up to like 15, so i figured thats plenty, all you really need is a few to keep cities next to each other from overlapping. The only one i found had a problem was layer 5 is apparently the one that the green pick cursor uses so I jump that one when selecting them. Since your unlikely to want to use the same color for 2 cities next to each other when dot mapping i figured using a layer for each color was the easiest way to do it then the user doesn't have to fiddle with them, just use different colors when next to another city.

Attached fixed code, also removed the extra junk from it, you guys probably don't want my mercurial repository too with it. :lol:

Now on to saving/restoring and putting it in as a bug mod :D
 

Attachments

  • Strategy Overlay.rar
    8.6 KB · Views: 82
Got it all integrated with bug, just add

Code:
<load mod="Strategy Overlay"/>

To CustomAssets/Config/init.xml and unzip it.

Alt-f10 opens the window, saving and loading works as long as you close the screen before you save. Hides all the dot-mapping when you close the screen and shows what you previously had when you open it.

Done with the latest 3.5 release, should work with any one though as it doesn't alter any other files besides the init.xml.

SS with bug 3.5 loaded and working



Now to figure out if anybody actually uses the lines in the regular strategy layer and if I should integrate that into this one as well.
 

Attachments

  • StrategyOverlay.zip
    8.7 KB · Views: 92
fantastic - I have 2 games that I am due to play. One of them is an almost no dot map game but the other one should be just right.
 
So I got to thinking about the other things that could be done with this, namely marking squares for certain strategic goals (chop this, leave this etc..). And being the nosy guy I am i did a grep for Plot against the xml files...

and in XML/Art/Civ4ArtDefines_Misc.xml this popped out at me...

<MiscArtInfo>
<Type>PLOT_TEXTURE</Type>
<Path>Art/Terrain/PlotTextures/PlotTexture.dds</Path>
<fScale>1.0</fScale>
<NIF>None</NIF>
<KFM>None</KFM>
</MiscArtInfo>

So since that particular texture didn't exist anywhere i started playing around(read as crashed civ 4 lots of times) with different images in that location.

After much fun I took this texture



And got this



Code:
from CvPythonExtensions import *
from SdToolkit import *

layer = 0

def drawPlotOverlay(x,y,plotTexture):
	sdEcho("Drawing Plot at :" + str(x) + "," + str(y) + " with texture #" + str(plotTexture))
	CyEngine().addColoredPlotAlt(x, y, plotTexture, layer, "COLOR_WHITE", 0.5)

def drawPlotGrid(x,y):
	for ix in range(8):
		for iy in range(4):
			drawPlotOverlay(x+ix,y+iy,ix + (iy*8))

Now enlarging/shrinking the texture just makes it use less/more of it for each one of the 32 squares, so i'm guessing its hard coded somewhere that it divides the texture into 8 colums 4 rows. But that does give us a bit of room to play with it, barring we don't care that people's numpad help stays relevant since replacing this file would overwrite that as well as a few WB things like the river placement overlay.

Either that or just using signs could work as well.
 
Actually, Art/Terrain/PlotTextures/PlotTexture.dds *does* exist in the original game (it's hiding in the original civ4 Assets1.fpk). See the spoilers in one of EF's first posts in this topic for an in-game image showing the 27 useful textures in that file if you don't feel like unpacking it.

In the original game, not only are the two styles of numpad help used but the circle is used for marking settler/worker suggestions and event locations, the empty rounded square is used for showing air mission range, and other stuff is used for things like worldbuilder cursors. You'd have to search the SDK for PLOT_STYLE_* to find all the current uses and some might come directly from the engine.

It is good to know we don't have to rely on the PlotStyle defines and can use the 5 blank spaces though.

Oh, and completely off-topic it looks like the Python API generator kinda screwed up its listing of the PlotStyle enums. :(
 
I did figure it was in a .fpk somewhere...one of these days i'll unpack those :D

Ya I figured those extra 5 spaces could be used for something, its too bad the amount of rows/colums it divides that texture into can't be changed as far as I can tell, that would be the goldmine :D
 
Just so I'm clear (I'm kinda frazzled right now), you're saying that no matter what size you make that image, it divides it into the 32 cells you stated and scales each individually across the plot you place it on? Bummer. I too was hoping each cell was a set size and using a different image size would give you more cells. :(

But hey, we have 5 more cells, and we could use some of the others for ourselves. Does anyone that knows enough to install and use BUG turn on numpad help? I doubt it.
 
Yup I tried making a 4x4 grid of that texture and you get 4 numbers in each plot. Also tried indicies higher than 31 when calling the draw function, got nothing there either.

Even tried using a multi-layer dds to see what would happen with that, it just pulls the top layer off the image.

That was kinda my thought as well with the numpad help. Or you could use those and make them into a legend type overlay, where you could have a small box in the corner of the overlay screen that read 1-some text etc etc. And let the player define the text.

On a side note I went through and localized what I did so far from the color defines and adding an xml file. Also decreased the size of the interface and text a bit, it was a bit too large on smaller resolutions imo.

Also found a pickPlot event handler in the CvEventManager.py that does respond to a plot being picked after you put the interface into PYTHON_PICK_PLOT mode. Decided not to use it for the dot mapping though since it doesn't allow you to pick plots that are in the fog of war which is probably going to be necessary for a strategy overlay, pointing out possible locations of where other civs are and such before unveiling that area I would think.

Edit: Just had another idea for strategy type signs, can the icons from like the Scoreboard be used on a sign? I haven't looked much at how the icons-in-a-font thing works yet. If so that offers a lot of possibility too. Small signs with an icon wouldn't be too intrusive.
 
New version of what I've been working on.

Put up a project page at
Launchpad Site
For bug tracking if anybody finds anything.

Stuff Added:

  • Added signs
  • Signs save and load on open/close
  • Hides both dot maps and signs when screen closes and restores on open
  • Pretty much leaves signs added in the default ui alone unless they are on the same plot (working on that part)
  • Cleaned up the interface, Sign and Dot mapper panels show/hide as you select each in the main panel
  • Moved hot keys out to the XML in config so they are easily changed
  • Got all the text moved out to XML, no translations yet :mischief:

To do:
  • Maybe create a unit that is just a flat rectangle with several textures and use that for a marker of sorts
  • Make the signs completely independent of the default UI's
  • Lines like the original strategy layer has
  • Get it to run stand-alone for multiplayer (maybe)

Sadly signs can't take Unicode strings so I can't put font symbols on them or just can't figure out how to. Anybody got any ideas here?

The color of the sign is tied to the player putting it down so I don't think I can change that since you can't see them if another player puts them down as far as I can tell.

The lines thing I'm going to have to dig a bit more. It looks like the calls are straight to the dll from the buttons but I think I can work around that by setting the globe layer from python.

Anyway a few screen shots of what it looks like now

Screen with a lot of crap added:
Spoiler :


Same screen with the overlay closed:
Spoiler :


Figured out how to do a custom pop up for the sign text in case I do figure out how to do font symbols on signs, the event handlers are all in place already this way. Pic of the pop up:
Spoiler :


I'd still like to find something besides signs for marking out individual tiles but besides a custom unit I can't think of anything else. Can't find anything that would allow you to map from a plot to screen coordinates to put down a image or screen widget which would be nice. Maybe I can get somebody to throw together a block unit and I can re-skin that for some different markers.

Any other ideas on what to throw in this to make it better?

Attached code, had to add my pop up event to CvUtil.SilentEvents to keep it from spewing debug text every time it was called. Also added in the enum for the event there since that's where the rest of them are located.
 

Attachments

  • StrategyOverlay.zip
    17.4 KB · Views: 123
Looks fantastic and I want to play with it. is this in BUG? What is the key strokes to bring this puppy up?
 
I was actually looking to add it into BUG today. I've got a couple questions and/or suggestions.

By stand-alone do you mean a separate release from BUG? If so, which is totally cool, are you willing to maintain both versions? I ask because I'd like to maybe add some stuff to it, and we'll need to figure out the best way to do the coding.

For example, the stuff in XML would need to go back into Python. I'm going to move the CvUtil stuff into the correct BUG way to do it (and that reminds me I need to put that into the docs, thanks!).

Okay, just one question I guess, here are some suggestions:

Instead of add and remove buttons, just make right-click do remove as per the normal way of placing signs and using WB. This means less clicking for the player.

Switch the separate windows to look more like WB. One window like your main window with icons for the different modes and another window that comes up with the colors when in the city mode. That's quite a lot more work, I know. :) Maybe you can talk NikNaks into creating icons for you, though he's been quite busy with school.

Alter CvMainInterface so it hides all the other crap when the SL is up, just like it does for WB. I'm going to take a look at MI to see how hard this will be. Hopefully I can create a single function in MI like shouldShowMainInterface() and shouldShowCityScreen() that perform all the new and old checks and then use that function throughout. This way when we add our next interface layer, it will require changing just those two functions.

I'll start taking a look at the stuff here and putting it into BUG proper. Great job on this; it's very nice. :goodjob:
 
Top Bottom