aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.odin40
-rw-r--r--src/time.odin2
-rw-r--r--src/ui_implementation.odin4
3 files changed, 27 insertions, 19 deletions
diff --git a/src/main.odin b/src/main.odin
index 5e2ddc2..1f2d46f 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -17,6 +17,8 @@ small_font : rl.Font
FRACT_MIN : f32 = 0.0
FRACT_MAX : f32 = 1.0
+dayrate : f64 = 3500
+
c0 : ^oui.Context
main :: proc() {
@@ -26,7 +28,6 @@ main :: proc() {
// for cache reasons, and to simplify the process of
// adding new Workdays to the array.
- dayrate : f64 = 3500
workdays : [dynamic]Workday
//resize(&workdays, 3)
the_big_sum : f64 = 0
@@ -92,8 +93,8 @@ main :: proc() {
using rl
- width: i32 = 700
- height: i32 = 400
+ width: i32 = 900
+ height: i32 = 500
InitWindow(width, height, "satscalc")
defer CloseWindow()
@@ -120,17 +121,31 @@ main :: proc() {
// Setting up the timelines
- for day in &workdays {
+
+ for day, f in &workdays {
beginning: Moment = {0, 0, day.call.day, day.call.month, day.call.year}
fmt.println("\nNew day!")
for each_block, i in day.blocks {
if i == day.total_timeblocks do break
- day.fractions[i].start = daycount(diff(beginning, each_block.start))
- day.fractions[i].end = daycount(diff(beginning, each_block.end))
+
+ start := daycount(diff(beginning, each_block.start))
+ end := daycount(diff(beginning, each_block.end))
+
+ day.fractions[i].start = start
+ day.fractions[i].end = end
+
+ if start < FRACT_MIN do FRACT_MIN = start
+ if end > FRACT_MAX do FRACT_MAX = end
+
fmt.println(day.fractions[i])
}
+ if f == 0 {
+ // First time through we set the normalization anchors to something we know is real
+ FRACT_MAX = workdays[0].fractions[0].start
+ FRACT_MIN = FRACT_MAX
+ }
}
for !WindowShouldClose() { // MAIN LOOP ---- MAIN LOOP ---- MAIN LOOP ---- MAIN LOOP
@@ -188,7 +203,7 @@ when true {
top_bar.layout_margin = 10
oui.item_insert(top_bar, label("Date", font, sizings.date, .Center))
- oui.item_insert(top_bar, label("Calltimes", font, sizings.call, .Center))
+ oui.item_insert(top_bar, label("Calltime", font, sizings.call, .Center))
top_bar.layout_cut_children = .Right
oui.item_insert(top_bar, label("Price", font, sizings.price, .Center))
@@ -241,17 +256,8 @@ when true {
// - - - - WORKDAYS - - - -
- FRACT_MAX = workdays[0].fractions[0].start
- FRACT_MIN = FRACT_MAX // TODO: Optimize this. It doesn't need to re-calculated every frame
-
for day, i in &workdays {
- for fract, i in day.fractions {
- if fract.start < FRACT_MIN do FRACT_MIN = fract.start
- if fract.end > FRACT_MAX do FRACT_MAX = fract.end
- if i+1 == day.total_timeblocks do break
- }
-
line := panel_line(middle_section, theme.background)
line.layout_cut_children = .Left
line.layout_cut_gap = 0
@@ -261,7 +267,7 @@ when true {
oui.item_insert(line, label(clockprint(day.call), font, sizings.call, .Center))
line.layout_cut_children = .Right
- oui.item_insert(line, label("3500 kr", font, sizings.price, .Center))
+ oui.item_insert(line, label(fmt.tprintf("%.2f kr", day.price), font, sizings.price, .Center))
oui.item_insert(line, label(clockprint(day.wrap), font, sizings.wrap, .Center))
line.layout_cut_children = .Fill
diff --git a/src/time.odin b/src/time.odin
index 90dca49..712136d 100644
--- a/src/time.odin
+++ b/src/time.odin
@@ -68,6 +68,7 @@ Workday :: struct {
// timeblock's start and end
fractions : [16]Fractionpair,
total_timeblocks : int,
+ price: f32,
}
@@ -193,6 +194,7 @@ new_workday :: proc(previous_wrap : Moment,
for each_block, i in blocks {
fmt.printf("Block %2i: %s $f: %i%% %s\n", i+1, toString(each_block), int((each_block.value-1)*100), each_block.reason)
+ price += f32(f64(dayrate/7.5) * f64(hourcount(each_block)) * f64(each_block.value))
}
return
diff --git a/src/ui_implementation.odin b/src/ui_implementation.odin
index 6839b57..71f0e94 100644
--- a/src/ui_implementation.odin
+++ b/src/ui_implementation.odin
@@ -51,8 +51,8 @@ sizings : Sizings = {
wrap = 90,
price = 100,
lunch = 100,
- timeline = 32,
- inter_timeline = 5,
+ timeline = 30,
+ inter_timeline = 3,
}
DAY_HEIGHT :: 35 // Only here for legacy UI