aboutsummaryrefslogtreecommitdiff
path: root/src/main.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.odin')
-rw-r--r--src/main.odin49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/main.odin b/src/main.odin
index 5f6449b..698f044 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -26,10 +26,30 @@ main :: proc() {
// for cache reasons, and to simplify the process of
// adding new Workdays to the array.
- workdays: [dynamic]^Workday
- resize(&workdays, 3)
+ dayrate : f64 = 3500
+ workdays : [dynamic]Workday
+ //resize(&workdays, 3)
+ the_big_sum : f64 = 0
- workday0: = new_workday({10, 22, 3, 5, 2023},
+ { // No need to keep this array in memory forever
+ c, _ := importICS("res/test.ics")
+
+ for thing, i in c {
+ fmt.println("\n\nAdding workday nr", i, "\n", toString(thing), "\n")
+ append(&workdays, new_workday({00, 00, 1, 1, 1850},
+ thing.start,
+ thing.end,
+ thing.end))
+ for each_block in workdays[i].blocks {
+ the_big_sum += f64(each_block.value) * (dayrate/7.5) * f64(hourcount(each_block))
+ }
+ }
+ }
+
+
+ //if true do return
+
+ /*workday0: = new_workday({10, 22, 3, 5, 2023},
{00, 08, 4, 5, 2023},
{00, 22, 4, 5, 2023},
{30, 21, 4, 5, 2023})
@@ -46,8 +66,9 @@ main :: proc() {
{15, 17, 6, 5, 2023},
{00, 17, 6, 5, 2023})
workdays[2] = &workday2
+ */
- slice.sort_by(workdays[:], lessWorkdayPtr)
+ slice.sort_by(workdays[:], lessWorkday)
//call_text: cstring = "00:00"
call_text: = make([]byte, 6)
@@ -58,12 +79,18 @@ main :: proc() {
defer delete(wrap_text)
wrap_text[len(wrap_text)-1] = 0
- date_text: = make([]byte, len(toString(workday0.call))+1 )
+ date_text: = make([]byte, len(toString(workdays[0].call))+1 )
defer delete(date_text)
wrap_text[len(wrap_text)-1] = 0
- total_sum: cstring = "3500 NOK + 26%" // Only here for legacy UI
- inc_soc: cstring = "4276 NOK" // Only here for legacy UI
+
+ total_sum: cstring = f64_to_cstring(the_big_sum)
+ defer delete(total_sum)
+
+ inc_soc: cstring = f64_to_cstring(the_big_sum*1.26)
+ defer delete(inc_soc)
+
+ text_height: f32
using rl
@@ -90,12 +117,12 @@ main :: proc() {
c0 = new(oui.Context)
defer free(c0)
- oui.context_init(c0, 1028, 1028 * 8)
+ oui.context_init(c0, 2048, 2048 * 8)
defer oui.context_destroy(c0)
// Setting up the timelines
- for day in workdays {
+ for day in &workdays {
beginning: Moment = {0, 0, day.call.day, day.call.month, day.call.year}
fmt.println("\nNew day!")
@@ -219,7 +246,7 @@ when true {
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 day, i in &workdays {
for fract, i in day.fractions {
if fract.start < FRACT_MIN do FRACT_MIN = fract.start
@@ -240,7 +267,7 @@ when true {
oui.item_insert(line, label(clockprint(day.wrap), font, sizings.wrap, .Center))
line.layout_cut_children = .Fill
- timeline(line, day)
+ timeline(line, &day)
}
new_workday := button("+", 100)
middle_section.layout_cut_children = .Top