Announcement

Collapse
No announcement yet.

Project: More Icons on Map

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Project: More Icons on Map

    Ok since I backed off from the new rules stuff ( for now) I was thinking about doing (what I thought) something simpler.

    Currently the game creates Icons around a city when a franchise is created etc. I wanted to create code that would let me push a file through and create an icon in the mod possibility of religions, or just re doing my showonmap for wonders or buildings and a few other ideas anyways the code currently works like this:

    Something happens (say franchise) it sets a bool in CityData.cpp then tiledraw.cpp accesses that bool in the tiledraw:: DrawCityNames function which then uses tiledraw:: DrawCityIcons.

    the Icons are a predetermine set of icons in the code. Hard coded. I creatd some code in drawcity icons for buildings (its at the end but I'll leave some original code):

    Code:
    void TiledMap:: DrawCityIcons(aui_Surface *surf, MapPoint const & pos, sint32 owner, bool fog, RECT &popRect,
    								BOOL isBioInfected, BOOL isNanoInfected, BOOL isConverted, 
    								BOOL isFranchised, BOOL isInjoined, BOOL wasHappinessAttacked,
    								sint32 bioInfectedOwner, sint32 nanoInfectedOwner, sint32 convertedOwner,
    								sint32 franchiseOwner, sint32 injoinedOwner, sint32 happinessAttackOwner,
    								uint32 slaveBits, BOOL isRioting, BOOL hasAirport, BOOL hasSleepingUnits,
    								BOOL isWatchful)
    {
    	TileSet	*   tileSet     = GetTileSet();
    	POINT       iconDim     = tileSet->GetMapIconDimensions(MAPICON_BIODISEASE);
        RECT		iconRect;
    	iconRect.left   = popRect.right + 3;
    	iconRect.right  = iconRect.left + iconDim.x + 1;
    	iconRect.top    = popRect.top;
    	iconRect.bottom = iconRect.top + iconDim.y + 1;
    
    	if (iconRect.left < 0 || iconRect.top < 0 || 
    		iconRect.right >= surf->Width() ||
    		iconRect.bottom >= surf->Height())
    		return;
    
    	Pixel16     color       = GetPlayerColor(owner, fog);
    	Pixel16 *   cityIcon;
    
    [i]...a bunch of bools like Watchful...[/i]
    	if (isWatchful) {
    		cityIcon = tileSet->GetMapIconData(MAPICON_WATCHFUL);
    		Assert(cityIcon); 
    		if (!cityIcon) return;
    		cityIcon = tileSet->GetMapIconData(MAPICON_WATCHFUL);
    		iconDim = tileSet->GetMapIconDimensions(MAPICON_WATCHFUL);
    
    		color = GetColor(COLOR_YELLOW, fog);
    		DrawColorizedOverlay(cityIcon, surf, iconRect.left, iconRect.top, color);
    		AddDirtyRectToMix(iconRect);
    
    		iconRect.left += iconDim.x;
    		iconRect.right += iconDim.x;
    	}
    //emod to draw city icons for wonders and buildings
    [b]	for(sint32 b = 0; b < g_theBuildingDB->NumRecords(); b++){
    		Unit unit;
    		CityData *cityData = unit.GetData()->GetCityData();
    		UnseenCellCarton	ucell;
    		owner = ucell.m_unseenCell->GetCityOwner();
    
    		if(cityData->GetImprovements() & ((uint64)1 << b)){
    			const BuildingRecord *rec = g_theBuildingDB->Get(b, g_player[owner]->GetGovernmentType());
    			MBCHAR const *	iconName;
    			cityIcon = 
    			if (rec->GetShowAsIcon(iconName))[/b]
    			{
    				color = GetColor(COLOR_YELLOW, fog);
    				DrawColorizedOverlay(iconName, surf, iconRect.left, iconRect.top, color);
    				AddDirtyRectToMix(iconRect);
    				iconRect.left += iconDim.x;
    				iconRect.right += iconDim.x;
    			}
    		}
    	}
    //end emod
    
    }

    I tried to access a file like martin set up for citystyles in scenarioeditor.cpp (using the CPIcon name). But my code here causes this problem:

    Code:
    tiledraw.cpp(4216) : error C2664: 'DrawColorizedOverlay' : cannot convert parameter 1 from 'const char *' to 'unsigned short *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    So I hope my problem is smple. Basically the drawing code only recognizezs these Pixel16 icon files but the way Martin called CPIcon was to use a char. Is there a way I can get it to draw the file? Or do I have to create a whole new drawing function?

    thanks.
    Last edited by Ekmek; January 4, 2007, 19:12.
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

  • #2
    hmmm no takers but 18 views...

    I guess my other option is to add a bunch more bools and functions as well as map icon file names. that will be easier for me to cut and paste but probably create a lot of unnecessary and inefficient code if only i could just do a for loop and plug in the file name

    back to the drawing board...
    Formerly known as "E" on Apolyton

    See me at Civfanatics.com

    Comment


    • #3
      Well I looked at some options....

      but first I found a defect
      The DrawCityIcons code calls for the hasAirport bool but then it isn't implement and there is an aircraft icon in the zfs and all the other "plumbing" isthere to suport it so I reimplemented it so that when a city has an airport it displays an aircraft icon. I think this was important for airlifting units between cities but I cant recall if this is still a feature or not.


      back to the options...
      1)Adding mapicons and bools seems the easiest but it requires modifying both citydata and unseencell files as well. I started on a IsCapitol bool to create a star at the city capitol to be shown on the map.

      2)I kept digging for a way to specify the file name and found some interesting stuff in LoadMapIcons but I need to find a way for it to return a Pixel16 in order to get the file to work. this may be more trouble than its worth.

      3) the other options I may try is the set image options but not sure how this will handle transparency issues and the like.
      Formerly known as "E" on Apolyton

      See me at Civfanatics.com

      Comment


      • #4
        Well adding new Map Icons appears to be fairly easy.

        what you see is the yellow star for an Army used to denote a capitol. The airplane icon is the zfs icon that is now called since I implemented the hasairport BOOL.

        so the code now can do this. One thing though is that I notice that if I have an airport and a capitol it moves the capitol star out and places the airplamne next to text so I think it places the icon in order of precedence.


        Well I hope I get time to create better Icons for these. I think the Capitol should be a larger star and to the left and atleast for my Call2Civ mod I'll make the airport an actual, to scale, airport that blends with te city. I also intend to add fire and smoke for rioting (but visible as compared to civ3) something I wanted to do to touch up the game.

        I'm looking into doing city expansion, visible wonders, and buildings, but that may take sometime since I have to add several bools. And since I'm digging in this code for awhile maybe I'll figure out how to add what the city is building underneath the name.

        anyways here's a screen shot
        Attached Files
        Formerly known as "E" on Apolyton

        See me at Civfanatics.com

        Comment


        • #5
          Well the plane looks like flying around the city. Maybe it is looking for some high rises to crash into.

          -Martin
          Civ2 military advisor: "No complaints, Sir!"

          Comment


          • #6
            It wont find many in ancient Carthage
            Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
            CtP2 AE Wiki & Modding Reference
            One way to compile the CtP2 Source Code.

            Comment


            • #7
              I think I may have found a way to improve the borders from just being think lines and instead make it more graphical using icons...but still working it.

              Also maq this work here *may* make it possible to add civ flags with units. but i'm still working it.
              Formerly known as "E" on Apolyton

              See me at Civfanatics.com

              Comment


              • #8
                Sounds interesting E. I saw the flag in the icons file, i thought perhaps we could open this up to one per civ just in a normal picture file like civ2. Of course its all easy to say.

                Ill keep an eye on it.
                Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
                CtP2 AE Wiki & Modding Reference
                One way to compile the CtP2 Source Code.

                Comment


                • #9
                  i think its possible to do a civ flag but its easier NOT to replace the heraldflag with the number of units there. this is because with 64 civ you'd have to do 12 files each. thats 768 graphic files. way too much work.

                  What I'm looking into is adding the civ flag but then changing the heraldarmy flag to be either just roman numerals or dashs (like civ3) and remove the flag graphic so the civ flag is there. I'm leaning towards the roman nmerals because its a better look IMHO. I'll post screenshots for opinion as I get to it.
                  Last edited by Ekmek; January 8, 2007, 23:20.
                  Formerly known as "E" on Apolyton

                  See me at Civfanatics.com

                  Comment


                  • #10
                    Okay this is the latest basically trying to clean upthe city name graphic to the left is the city's population the number on the right is turns to growth. Ideally I'd like to make it a string next to the city name (something civ3 did well) but I have to figure out how to hide it. I may find a way to add what the city is building as well. But now I'm still frustrated as to why I cant get the pop box bigger to match the cityname.

                    A second issue I've tried is adding the mapicon for borders but for somereason it just disappears instead of drawing the graphic. its driving me mad
                    Attached Files
                    Formerly known as "E" on Apolyton

                    See me at Civfanatics.com

                    Comment


                    • #11
                      I'm having a cheat error the code works fine when its just playing but if unreaveal the map i get a crash with my drawcity icons. i think the problem is because therer is a visible player switch and since i based the icons off of the next pop rect i think it messes up there. not sure ho wto fix it though.
                      Formerly known as "E" on Apolyton

                      See me at Civfanatics.com

                      Comment


                      • #12
                        still monkeying with this. So far I've set it up to enable up to 10 different city religions.

                        how it works, in my Call2Civ mod is that a unit that can convert has a settlebuilding flag. if it converts a city it will create that building in the city. if the city has a flag like IsReligion1 then the IsReligion1 Icon will appear in the city.

                        The other way religion works is once you achieve a feat anyone can build a wonder of that religion. that wonder gets gold from all of the holy buildings from all players. that holy building enables the building of religious units that spread more of those buildings by conversion. You cantsell the holy buildings but reforming destroys them.

                        any ways here is a screen shot of all five religions i have call2civ
                        Attached Files
                        Formerly known as "E" on Apolyton

                        See me at Civfanatics.com

                        Comment


                        • #13
                          Amazing progress so far E
                          Call to Power 2: Apolyton Edition - download the latest version (12th June 2011)
                          CtP2 AE Wiki & Modding Reference
                          One way to compile the CtP2 Source Code.

                          Comment


                          • #14
                            Yeah, really amazing .

                            How did you manage to get such a clean picture, E? After revision 682, I am seeing some strange border patterns. At least, when I do not move the mouse too much - then the game will crash.

                            Comment


                            • #15
                              Example border image:
                              Attached Files

                              Comment

                              Working...
                              X