CyEngine().addColoredPlotAlt(...) Question ?

Sto

Should i code today ...
Joined
Dec 15, 2005
Messages
1,144
Location
Marseille (France)
I want to give more information to the player when selecting a worker or a unit that can alter the terrain by using different PlotStyles . ex: a circle for a tile not improved , a square for a tile with a bonus not improved and not owned etc...

So after a few tests , there is a lot of things i don't understand :

1 : Where does this is implemented ? I can't achieve to found where this is basicaly implemented for workers, fishing boats and settler ...

2 : what's the meening of iLayer ( ex :PlotLandscapeLayers.PLOT_LANDSCAPE_LAYER_WORLD_BUILDER , PlotLandscapeLayers.PLOT_LANDSCAPE_LAYER_REVEALED_PLOTS etc ...) and where can i find a list of them . i found no note about that into the API .

3 : with the structure of the function ,i don't understand how that's goes in multiplayer games . it seems you need to use clearColoredPlots(INT iLayer) to erase all sign and then redraw all added feature for each player each time you select another unit ( but this should depend on the answer of the 2 first question , i guess :confused: )

thanks for any help :)
Tcho !
 
Sto said:
I want to give more information to the player when selecting a worker or a unit that can alter the terrain by using different PlotStyles . ex: a circle for a tile not improved , a square for a tile with a bonus not improved and not owned etc...

So after a few tests , there is a lot of things i don't understand :

1 : Where does this is implemented ? I can't achieve to found where this is basicaly implemented for workers, fishing boats and settler ...

Every time a new unit is selected (and possibly in other cases that I don't know of), the SDK calls the CvGame::updateColoredPlots() function. Luckily, there is also a python hook for this function located in CvGameUtils.py, so you can add all your calls there. Note that the python function is called before the rest of the SDK function (which will place things such as the bombers range or a currently selected cities rally plot), so if you color a plot using a specific layer and later on the SDK changes the color on that layer, then it will overwrite yours (I believe that is the case anyway, you can try it out). You might need to find out how to determine what the currently selected unit is, since that is not in the arguments for the python function.

2 : what's the meening of iLayer ( ex :PlotLandscapeLayers.PLOT_LANDSCAPE_LAYER_WORLD_BUILDER , PlotLandscapeLayers.PLOT_LANDSCAPE_LAYER_REVEALED_PLOTS etc ...) and where can i find a list of them . i found no note about that into the API .

These are all the layers and their values: you can find them in the SDK in the CvEnums file:

Code:
enum DllExport PlotLandscapeLayers		// Exposed to Python
{
	PLOT_LANDSCAPE_LAYER_ALL = -1,
	PLOT_LANDSCAPE_LAYER_BASE = 0,
	PLOT_LANDSCAPE_LAYER_RECOMMENDED_PLOTS = 1,
	PLOT_LANDSCAPE_LAYER_WORLD_BUILDER = 2,
	PLOT_LANDSCAPE_LAYER_NUMPAD_HELP = 2,
	PLOT_LANDSCAPE_LAYER_HIGHLIGHT_PLOTS = 2,
	PLOT_LANDSCAPE_LAYER_REVEALED_PLOTS = 1,
};

As you can see, some of the layers serve more than one purpose. The idea is that all color changes of a single layer can be changed in one swoop. For example, the CvGame::updateColoredPlots() code uses this...

Code:
	gDLL->getEngineIFace()->clearColoredPlots(PLOT_LANDSCAPE_LAYER_BASE);

	if (!gDLL->GetWorldBuilderMode())
	{
		gDLL->getEngineIFace()->clearColoredPlots(PLOT_LANDSCAPE_LAYER_RECOMMENDED_PLOTS);
	}


3 : with the structure of the function ,i don't understand how that's goes in multiplayer games . it seems you need to use clearColoredPlots(INT iLayer) to erase all sign and then redraw all added feature for each player each time you select another unit ( but this should depend on the answer of the 2 first question , i guess :confused: )

Correct, hopefully the answer to #1 will help. As for multiplayer games, realize that many of the colored plots will be different from player to player. For example, when you have a bomber selected, the colored plots are drawn on your screen, but not on the other persons. Just like showing civics screen or a showing a popup, these differences have no real effect on the game state, but rather the interface that each player sees the game state with.

Edit: Also, in case you're interested, here is the list for the PlotStyles, located in the same file as the PlotLandscapeLayers:
Code:
enum DllExport PlotStyles						// Exposed to Python
{
	PLOT_STYLE_NONE = -1,

	//first row
	PLOT_STYLE_NUMPAD_1 = 0,
	PLOT_STYLE_NUMPAD_2,
	PLOT_STYLE_NUMPAD_3,
	PLOT_STYLE_NUMPAD_4,
	PLOT_STYLE_NUMPAD_6,
	PLOT_STYLE_NUMPAD_7,
	PLOT_STYLE_NUMPAD_8,
	PLOT_STYLE_NUMPAD_9,

	//second row
	PLOT_STYLE_NUMPAD_1_ANGLED = 8,
	PLOT_STYLE_NUMPAD_2_ANGLED,
	PLOT_STYLE_NUMPAD_3_ANGLED,
	PLOT_STYLE_NUMPAD_4_ANGLED,
	PLOT_STYLE_NUMPAD_6_ANGLED,
	PLOT_STYLE_NUMPAD_7_ANGLED,
	PLOT_STYLE_NUMPAD_8_ANGLED,
	PLOT_STYLE_NUMPAD_9_ANGLED,

	//third row
	PLOT_STYLE_BOX_FILL = 16,
	PLOT_STYLE_BOX_OUTLINE,
	PLOT_STYLE_RIVER_SOUTH,
	PLOT_STYLE_RIVER_EAST,
	PLOT_STYLE_SIDE_ARROWS,
	PLOT_STYLE_CIRCLE,
	PLOT_STYLE_TARGET,
	PLOT_STYLE_DOT_TARGET,

	//fourth row
	PLOT_STYLE_WAVES = 24,
	PLOT_STYLE_DOTS,
	PLOT_STYLE_CIRCLES,
};
 
Many thanks for help ! :)

there is all i need !!!

I think i will have a lot of tests to do and it seems to be a little hard for me , but i will learn a lot of things trying to implement this . You also give me a lot of tracks to find the information by myself ( i never try to find implementation in SDK or variable types , that will be helpfull )

Thanks again ! :goodjob:

Tcho !
 
Back
Top Bottom