Skip to content

Commit

Permalink
Merge pull request #1 from ynohtna92/panorama
Browse files Browse the repository at this point in the history
Panorama ready!
  • Loading branch information
ynohtna92 committed Oct 16, 2015
2 parents 3833a3a + 9f7ab23 commit 2a46270
Show file tree
Hide file tree
Showing 101 changed files with 198 additions and 15,424 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CustomTimer
A Flash Module for custom timers in Dota 2
A Panorama Module for custom timers in Dota 2
The Scaleform Module has been depreciated and can be found [here](https://github.com/ynohtna92/CustomTimer/releases/tag/Scaleform)

<p align="center">
<img src="https://raw.githubusercontent.com/ynohtna92/CustomTimer/master/src/CustomTimerPreview.PNG"/>
Expand All @@ -9,23 +10,25 @@ A Flash Module for custom timers in Dota 2

Usage
-----
Places the flash3 and script files in the correct location in your custom game directory.
Places the panorama and script files in the correct location in your custom game directory.

In lua use
````lua
FireGameEvent('cgm_timer_display', { timerMsg = "Remaining", timerSeconds = 10, timerWarning = 10, timerEnd = false, timerPosition = 0})
CustomGameEventManager:Send_ServerToAllClients("display_timer", {msg="hi", duration=10, mode=0, endfade=false, position=0, warning=5, paused=false, sound=true} )
````
**Where:**
- timerMsg (String) = Your Message
- timerSeconds (Integer) = Duration in seconds
- timerEnd (Boolean) = When true the timer will not disappear when it hits 0
- timerPosition (Integer) = 0 (Display Center), 1 (Display Left), 2 (Display Right), 4 (Display Center - offset)
- timerWarning (Integer) = -1 (Disable, Will default to '0' Red) - Changes the timer color to red when the timer is low

- msg (String) = Your Message
- duration (Integer) = Duration in seconds
- endfade (Boolean) = When true the timer will not disappear when it hits 0
- position (Integer) = 0 (Display Center), 1 (Display Left), 2 (Display Right), 4 (Display Center - offset)
- warning (Integer) = -1 (Disable, Will default to '0' Red) - Changes the timer color to red when the timer is low
- paused (Boolean) = true (Pause), false (Unpause)
- sound (Boolean) = true (Warning Sound On), false (Warning Sound Off)

You may also call this lua function to pause the timer.
```lua
FireGameEvent('cgm_timer_pause', { timePaused = true})
CustomGameEventManager:Send_ServerToAllClients("pause_timer", {pause=true} )
```

**Where:**
- timePaused (Boolean) = true (Pause), false (Unpause)
- paused (Boolean) = true (Pause), false (Unpause)
File renamed without changes
17 changes: 17 additions & 0 deletions panorama/layout/custom_game/custom_timer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<root>
<styles>
<include src="s2r://panorama/styles/dotastyles.vcss_c" />
<include src="file://{resources}/styles/custom_game/custom_timer.css" />
</styles>
<scripts>
<include src="file://{resources}/scripts/custom_game/custom_timer.js" />
</scripts>
<Panel hittest="false" class="BaseHud">
<Panel hittest="false" class="Clip">
<Panel hittest="false" id="TimerBox" class="TimerBox">
<Label id="TimerMsg" text="Remaining"/>
<Label id="TimerRemaining" text="00:00:00"/>
</Panel>
</Panel>
</Panel>
</root>
5 changes: 5 additions & 0 deletions panorama/layout/custom_game/custom_ui_manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<root>
<Panel>
<CustomUIElement type="Hud" layoutfile="file://{resources}/layout/custom_game/custom_timer.xml" />
</Panel>
</root>
104 changes: 104 additions & 0 deletions panorama/scripts/custom_game/custom_timer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
var COLOUR_NORMAL = "#FFFFFF";
var COLOUR_WARNING = "#DF161F";
var TIMER_INTERVAL = 0.05;
var FADE_INTERVAL = 0.025;

var startTime = -1;
var timerDuration = 0;
var timerMode = 0; // Countdown = 0, Countup = 1
var timerMessage = "Remaining";
var timerEnd = false; // When true, hide on timer end
var timerPosition = 0;
var timerPaused = false;
var timerSound = false;
var timer = null;
var timerWarning = -1; // Second to start warning at from end (-1 Disabled)
var timerLast = 0;

var timer = $( "#TimerBox" );
var hideMarginTop = -78;
var initMarginTop = 22;
var curtMarginTop = hideMarginTop;

function UpdateTimer() {
if (timerPaused)
startTime += 0.05;

var timerTextRemain = $( "#TimerRemaining" );
var time = Game.GetGameTime() - startTime;
var remaining = Math.ceil(timerDuration - time);

if (remaining <= timerWarning && timerWarning != -1) {
if (remaining != timerLast && timerSound) {
timerLast = remaining;
$.Msg('Beep');
Game.EmitSound("BUTTON_CLICK_MINOR");
}
timerTextRemain.style['color'] = COLOUR_WARNING;
}
else
timerTextRemain.style['color'] = COLOUR_NORMAL;
if (remaining >= 0) {
if (timerMode == 0)
timerTextRemain.text = FormatTime(remaining);
else
timerTextRemain.text = FormatTime(time);
}
if (time < timerDuration)
$.Schedule(TIMER_INTERVAL, function(){UpdateTimer();});
else
timer.RemoveClass("FadeIn");
}

function FadeIn() {
curtMarginTop += 10;
timer.style["margin-top"] = curtMarginTop + "px";
$.Msg(curtMarginTop);
if (curtMarginTop != initMarginTop)
$.Schedule(FADE_INTERVAL, function(){FadeIn();});
}

function DisplayTimer( table ) {
timerMessage = table.msg || "Remaining";
timerDuration = table.duration;
timerMode = table.mode;
timerEnd = table.endfade;
timerPosition = table.position;
timerWarning = table.warning;
timerPaused = table.paused;
timerSound = table.sound;
startTime = Game.GetGameTime();
var timerTextMsg = $( "#TimerMsg" );
timerTextMsg.text = $.Localize(timerMessage);
UpdateTimer();
//curtMarginTop = hideMarginTop;
//timer.style["margin-top"] = curtMarginTop + "px";
//FadeIn();
timer.AddClass("FadeIn");
}

function PauseTimer( bool ) {
timerPaused = bool.pause;
}

function FormatTime( seconds ) {
var hours = Math.floor(seconds / 3600);
var remainder = seconds % 3600;
var minutes = Math.floor(remainder / 60);
var seconds = Math.floor(remainder % 60);
var s = "";
var m = "";
var h = "";
if (seconds < 10)
s = "0";
if (minutes < 10)
m = "0";
if (hours < 10)
h = "0";
return h + hours + ":" + m + minutes + ":" + s + seconds;
}

(function () {
GameEvents.Subscribe( "display_timer", DisplayTimer );
GameEvents.Subscribe( "pause_timer", PauseTimer );
})();
58 changes: 58 additions & 0 deletions panorama/styles/custom_game/custom_timer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.BaseHud
{
width: 100%;
height: 100%;
flow-children: down;
}

.Clip
{
clip: rect(44px, 300px, 110px,0px);
horizontal-align: right;
width: 300px;
height: 110px;
}

.TimerBox
{
width: 261px;
height: 80px;
background-image: url("file://{resources}/images/custom_game/custom_timer_bg.png");
background-size: 100%;
horizontal-align: right;
margin-top: -78px;
margin-right: 15px;
z-index: -10;
transition-property: transform;
transition-duration: 0.25s;
transition-timing-function: linear;
}

.TimerBox Label
{
color: #FFFFFF;
font-size: 21px;
font-weight: bold;

}

#TimerMsg
{
margin-top: 34px;
margin-left: 20px;
text-align: center;
width: 130px;
}

#TimerRemaining
{
margin-top: 34px;
margin-left: 144px;
text-align: center;
width: 100px;
}

.FadeIn
{
transform: translateY(100px);
}
Binary file removed resource/flash3/CustomUI_Timer.swf
Binary file not shown.
75 changes: 0 additions & 75 deletions resource/flash3/custom_ui.txt

This file was deleted.

35 changes: 0 additions & 35 deletions scripts/custom_events.txt

This file was deleted.

Loading

0 comments on commit 2a46270

Please sign in to comment.