Skip to content

Commit

Permalink
Ported Interest Scaleform to panorama
Browse files Browse the repository at this point in the history
  • Loading branch information
ynohtna92 committed Dec 4, 2015
1 parent 0aaa885 commit 2b859ce
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
GameUI.CustomUIConfig().team_colors[DOTATeam_t.DOTA_TEAM_CUSTOM_6] = "#64BEC8;";
</script>
<Panel>
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/interest.xml" />
</Panel>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<root>
<styles>
<include src="s2r://panorama/styles/dotastyles.vcss_c" />
<include src="file://{resources}/styles/custom_game/interest.css" />
</styles>
<scripts>
<include src="file://{resources}/scripts/custom_game/interest.js" />
</scripts>
<Panel hittest="false" class="BaseHud">
<Panel hittest="false" id="Interest">
<Panel hittest="false" id="InterestBar" onmouseover="RemoveStyle(InterestTooltip, hide)" onmouseout="AddStyle(InterestTooltip, hide)">
<Panel hittest="false" id="InterestBarGold"/>
<Panel hittest="false" id="InterestBarOverlay"/>
<Image id="InterestCoin" src="file://{images}/custom_game/interest/gold.png"/>
<Label id="InterestLabel" text="Interest (2%)"/>
</Panel>
<Panel hittest="false" id="InterestTooltip" class="hide">
<Label id="TooltipLabel" text="Total Gold From Interest"/>
<Label id="TooltipAmount" text="0"/>
</Panel>
</Panel>
</Panel>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"use strict";

var INTEREST_INTERVAL = 15;
var INTEREST_RATE = 0.02;

var INTEREST_REFRESH = 0.05;

var interest = $( "#Interest" );
var interestBarGold = $( "#InterestBarGold" );
var tooltipAmount = $( "#TooltipAmount" );

var timerEnd = 0;
var totalGoldEarned = 0;
var enabled = false;
var timerStart = 0;

function UpdateInterest() {
if (enabled) {
if ( Game.GetGameTime() > timerEnd ) {
timerStart = timerEnd;
timerEnd += INTEREST_INTERVAL;
}
var widthPercentage = 100 - Math.floor((timerEnd - Game.GetGameTime())/INTEREST_INTERVAL * 100);
interestBarGold.style["width"] = widthPercentage+"%";
}
$.Schedule(INTEREST_REFRESH, function(){UpdateInterest();});
}

function DisplayInterest( table ) {
timerStart = Game.GetGameTime();
timerEnd = Game.GetGameTime() + INTEREST_INTERVAL;
interest.visible = true;
enabled = table.enabled;
INTEREST_INTERVAL = table.interval;
INTEREST_RATE = table.rate;
}

function InterestEarned( table ) {
enabled = true;
interest.visible = true;
// Sync
timerStart = Game.GetGameTime();
timerEnd = timerStart + INTEREST_INTERVAL;
totalGoldEarned += table.goldEarned;
tooltipAmount.text = totalGoldEarned;
}

(function () {
UpdateInterest();
interest.visible = false;
GameEvents.Subscribe( "etd_display_interest", DisplayInterest );
GameEvents.Subscribe( "etd_earned_interest", InterestEarned );
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.BaseHud
{
width: 100%;
height: 100%;
flow-children: down;
}

#Interest
{
horizontal-align: right;
margin-top: 4px;
margin-right: 14px;
z-index: 15;
flow-children: down;
}

#InterestBar
{
width: 240px;
height: 36px;
background-image: url("file://{resources}/images/custom_game/interest/interest_gray.png");
background-size: 100%;
margin-bottom: 10px;
}

#InterestBarGold
{
width: 100%;
height: 100%;
background-image: url("file://{resources}/images/custom_game/interest/interest_gold.png");
background-size: 100%;
}

#InterestBarOverlay
{
width: 100%;
height: 100%;
background-image: url("file://{resources}/images/custom_game/interest/interest_overlay.png");
background-size: 100%;
}

#InterestTooltip
{
width: 240px;
height: 70px;
background-color: #111111;
padding: 8px;
flow-children: down;
}

.hide
{
visibility: collapse;
}

#InterestCoin
{
margin-top: 3px;
width: 30px;
height: 30px;
margin-left: 20px;
}

#InterestLabel
{
margin-top: 4px;
font-size: 23px;
font-weight: bold;
color: #FF9900;
text-shadow: 0px 0px 3px 4.0 #000;
text-align: center;
width: 100%;
text-align: center;
}

#TooltipLabel
{
width: 100%;
font-size: 20px;
font-weight: bold;
color: #FFF;
text-shadow: 5px 5px #000;
text-align: center;
}

#TooltipAmount
{
width: 100%;
text-align: center;
font-size: 24px;
font-weight: bold;
color: #FF9900;
text-shadow: 0px 0px 5px 5.0 #000;
}
2 changes: 2 additions & 0 deletions game/dota_addons/element_td/scripts/vscripts/interest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function InterestManager:StartInterestTimer()
hero:SetGold(gold, true);
PopupGoldGain(hero, interest);
goldEarnedData["player" .. ply:GetPlayerID()] = interest;
CustomGameEventManager:Send_ServerToPlayer( ply, "etd_earned_interest", { goldEarned=interest } )
end
end
end
Expand All @@ -31,6 +32,7 @@ function InterestManager:StartInterestTimer()
return INTEREST_INTERVAL;
end
});
CustomGameEventManager:Send_ServerToAllClients("etd_display_interest", { interval=INTEREST_INTERVAL, rate=INTEREST_RATE, enabled=true } )
FireGameEvent("etd_start_interest_timer", {duration = INTEREST_INTERVAL});

end
Expand Down

2 comments on commit 2b859ce

@MNoya
Copy link
Owner

@MNoya MNoya commented on 2b859ce Dec 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get rid of the FireGameEvents and flash3/custom_ui.txt elements too, right?

@ynohtna92
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll do that once all Scaleform elements have been ported, I'm just leaving it alone for now.

Please sign in to comment.