MCPcopy Create free account
hub / github.com/SolarLune/masterplan / Draw

Method Draw

contents.go:2104–2169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2102}
2103
2104func (tc *TimerContents) Draw() {
2105
2106 p := float32(0)
2107
2108 // Numbered mode
2109
2110 modeGroup := int(tc.Card.Properties.Get("mode group").AsFloat())
2111
2112 if modeGroup == 1 && tc.CountdownTime > 0 {
2113
2114 if tc.TimerValue > 0 {
2115 p = float32(tc.TimerValue) / float32(tc.CountdownTime)
2116 }
2117
2118 } else if tc.ClockBecameInPhase {
2119 p = 1
2120 }
2121 tc.PercentageComplete += (p - tc.PercentageComplete) * 6 * globals.DeltaTime
2122
2123 if tc.PercentageComplete < 0 {
2124 tc.PercentageComplete = 0
2125 } else if tc.PercentageComplete > 1 {
2126 tc.PercentageComplete = 1
2127 }
2128
2129 src := &sdl.FRect{0, 0, tc.Card.Rect.W * tc.PercentageComplete, tc.Card.Rect.H}
2130 dst := &sdl.FRect{0, 0, float32(src.W), float32(src.H)}
2131 dst.X = tc.Card.DisplayRect.X
2132 dst.Y = tc.Card.DisplayRect.Y
2133 dst = tc.Card.Page.Project.Camera.TranslateRect(dst)
2134
2135 barColor := getThemeColor(GUITimerColor)
2136 if tc.Card.CustomColor != nil {
2137 barColor = tc.Card.CustomColor
2138 }
2139 tc.Card.Result.Texture.SetColorMod(barColor.RGB())
2140
2141 tc.Card.Result.Texture.SetAlphaMod(255)
2142 globals.Renderer.RenderTexture(tc.Card.Result.Texture, src, dst)
2143
2144 tc.DefaultContents.Draw()
2145
2146 if modeGroup == 2 && !tc.TargetTimeLabel.Editing {
2147 txt := tc.TargetTimeLabel.TextAsString()
2148 color := getThemeColor(GUIMenuColor)
2149 x := float32(0)
2150
2151 if tc.CheckboxOn {
2152 if tc.ClockInPhase() {
2153 txt = "Active: " + txt
2154 color = getThemeColor(GUICompletedColor)
2155 } else {
2156 color = getThemeColor(GUICheckboxColor)
2157 }
2158 // x += 46
2159 }
2160
2161 textSize := globals.TextRenderer.MeasureText([]rune(txt), 0.5)

Callers

nothing calls this directly

Calls 10

ClockInPhaseMethod · 0.95
getThemeColorFunction · 0.85
DrawLabelFunction · 0.85
AsFloatMethod · 0.80
TranslateRectMethod · 0.80
RGBMethod · 0.80
TextAsStringMethod · 0.80
MeasureTextMethod · 0.80
DrawMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected