Ticket #1365: hero-overlay-alpha.patch

File hero-overlay-alpha.patch, 8.3 KB (added by Deiz, 12 years ago)
  • binaries/data/mods/public/simulation/templates/template_unit_hero.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero.xml
    index f7e47eb..e591ba2 100644
    a b  
    4949  </Minimap>
    5050  <Selectable>
    5151    <Overlay>
     52      <AlwaysVisible />
    5253      <Texture>
    5354        <MainTexture>star/256x256.png</MainTexture>
    5455        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry.xml
    index 3db18aa..ac5680d 100644
    a b  
    5353  </Minimap>
    5454  <Selectable>
    5555    <Overlay>
     56      <AlwaysVisible />
    5657      <Texture>
    5758        <MainTexture>star/256x256.png</MainTexture>
    5859        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry_archer.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry_archer.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry_archer.xml
    index 05a0a20..02ff6ca 100644
    a b Ranged attack 2x vs. spearmen. Ranged attack 1.5x vs. Swordsmen.</Tooltip>  
    6262  </Minimap>
    6363  <Selectable>
    6464    <Overlay>
     65      <AlwaysVisible />
    6566      <Texture>
    6667        <MainTexture>star/256x256.png</MainTexture>
    6768        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry_javelinist.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry_javelinist.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero_cavalry_javelinist.xml
    index fa52c94..38151b1 100644
    a b  
    5252  </Minimap>
    5353  <Selectable>
    5454    <Overlay>
     55      <AlwaysVisible />
    5556      <Texture>
    5657        <MainTexture>star/256x256.png</MainTexture>
    5758        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • binaries/data/mods/public/simulation/templates/template_unit_hero_infantry.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero_infantry.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero_infantry.xml
    index 2bdeecb..1b2b5ce 100644
    a b  
    5151  </Minimap>
    5252  <Selectable>
    5353    <Overlay>
     54      <AlwaysVisible />
    5455      <Texture>
    5556        <MainTexture>star/256x256.png</MainTexture>
    5657        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • binaries/data/mods/public/simulation/templates/template_unit_hero_infantry_archer.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero_infantry_archer.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero_infantry_archer.xml
    index 32ab5a9..29b34bc 100644
    a b Counters Swordsmen and Cavalry Spearmen. Countered by Skirmishers and other Cava  
    5454  </Minimap>
    5555  <Selectable>
    5656    <Overlay>
     57      <AlwaysVisible />
    5758      <Texture>
    5859        <MainTexture>star/256x256.png</MainTexture>
    5960        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • binaries/data/mods/public/simulation/templates/template_unit_hero_infantry_javelinist.xml

    diff --git a/binaries/data/mods/public/simulation/templates/template_unit_hero_infantry_javelinist.xml b/binaries/data/mods/public/simulation/templates/template_unit_hero_infantry_javelinist.xml
    index 6d7ba9b..6f87b50 100644
    a b  
    5858  </Minimap>
    5959  <Selectable>
    6060    <Overlay>
     61      <AlwaysVisible />
    6162      <Texture>
    6263        <MainTexture>star/256x256.png</MainTexture>
    6364        <MainTextureMask>star/256x256_mask.png</MainTextureMask>
  • source/simulation2/components/CCmpSelectable.cpp

    diff --git a/source/simulation2/components/CCmpSelectable.cpp b/source/simulation2/components/CCmpSelectable.cpp
    index 6650e35..faf15c5 100644
    a b public:  
    8484                "</element>"
    8585            "</optional>"
    8686            "<element name='Overlay' a:help='Specifies the type of overlay to be displayed when this entity is selected'>"
     87                "<optional>"
     88                    "<element name='AlwaysVisible' a:help='If this element is present, the minimum alpha of the overlay will be 40%'>"
     89                        "<empty/>"
     90                    "</element>"
     91                "</optional>"
    8792                "<choice>"
    8893                    "<element name='Texture' a:help='Displays a texture underneath the entity.'>"
    8994                        "<element name='MainTexture' a:help='Texture to display underneath the entity. Filepath relative to art/textures/selection/.'><text/></element>"
    public:  
    102107    {
    103108        m_EditorOnly = paramNode.GetChild("EditorOnly").IsOk();
    104109
     110        // Certain special units always have their selection overlay shown.
     111        m_AlphaMin = paramNode.GetChild("Overlay").GetChild("AlwaysVisible").IsOk() ? .4 : 0.;
     112
    105113        const CParamNode& textureNode = paramNode.GetChild("Overlay").GetChild("Texture");
    106114        const CParamNode& outlineNode = paramNode.GetChild("Overlay").GetChild("Outline");
    107115
    public:  
    152160
    153161    virtual void SetSelectionHighlightAlpha(float alpha)
    154162    {
     163        alpha = std::max(m_AlphaMin, alpha);
     164
    155165        // set up fading from the current value (as the baseline) to the target value
    156166        m_FadeBaselineAlpha = m_Color.a;
    157167        m_FadeDeltaAlpha = alpha - m_FadeBaselineAlpha;
    private:  
    193203   
    194204    /// Current selection overlay color. Alpha component is subject to fading.
    195205    CColor m_Color;
     206    /// Minimum value for current selection overlay alpha.
     207    float m_AlphaMin;
    196208    /// Baseline alpha value to start fading from. Constant during a single fade.
    197209    float m_FadeBaselineAlpha;
    198210    /// Delta between target and baseline alpha. Constant during a single fade. Can be positive or negative.
  • source/simulation2/components/CCmpTemplateManager.cpp

    diff --git a/source/simulation2/components/CCmpTemplateManager.cpp b/source/simulation2/components/CCmpTemplateManager.cpp
    index d69cc36..72e6727 100644
    a b void CCmpTemplateManager::ConstructTemplateActor(const std::string& actorName, C  
    382382                          "<VisualActor><Actor>" + name + "</Actor></VisualActor>"
    383383                          "<Selectable>"
    384384                              "<EditorOnly/>"
    385                               "<Overlay><Texture><MainTexture>actor.png</MainTexture><MainTextureMask>actor_mask.png</MainTextureMask></Texture></Overlay>"
     385                                 "<Overlay><AlwaysVisible/><Texture><MainTexture>actor.png</MainTexture><MainTextureMask>actor_mask.png</MainTextureMask></Texture></Overlay>"
    386386                          "</Selectable>"
    387387                      "</Entity>";
    388388
  • source/simulation2/tests/test_CmpTemplateManager.h

    diff --git a/source/simulation2/tests/test_CmpTemplateManager.h b/source/simulation2/tests/test_CmpTemplateManager.h
    index 0c3a0e5..0af29ed 100644
    a b public:  
    7878        const CParamNode* actor = tempMan->LoadTemplate(ent2, "actor|example1", -1);
    7979        TS_ASSERT(actor != NULL);
    8080        TS_ASSERT_WSTR_EQUALS(actor->ToXML(),
    81                 L"<Selectable><EditorOnly></EditorOnly><Overlay><Texture><MainTexture>actor.png</MainTexture><MainTextureMask>actor_mask.png</MainTextureMask></Texture></Overlay></Selectable>"
     81                L"<Selectable><EditorOnly></EditorOnly><Overlay><AlwaysVisible></AlwaysVisible><Texture><MainTexture>actor.png</MainTexture><MainTextureMask>actor_mask.png</MainTextureMask></Texture></Overlay></Selectable>"
    8282                L"<VisualActor><Actor>example1</Actor><SilhouetteDisplay>false</SilhouetteDisplay><SilhouetteOccluder>false</SilhouetteOccluder></VisualActor>");
    8383
    8484        const CParamNode* preview = tempMan->LoadTemplate(ent2, "preview|unit", -1);