<commit_before>module Scorched.Model.MainMenu exposing (..)

import Dict exposing (Dict)

import Scorched.Model.Types exposing (..)
import Scorched.Model.Geometry exposing (Dimension)

import Scorched.Model.Sky as Sky
import Scorched.Model.World as World

import Scorched.Model.Helper as Helper

default : MainMenuData
default =
  { controls = defaultControls
  , world = World.empty
  }

defaultControls : Dict String Control
defaultControls =
  Dict.fromList
    (List.map
      (\control -> (control.label, control))
        [ Control "Start" 'S' {x=7, y=12} (Button (ButtonSpec {width=82, height=19} False NoOp))
        , Control "Sound…" 'o' {x=7, y=102} (Button (ButtonSpec {width=56, height=19} False NoOp))
        , Control "Hardware…" 'H' {x=7, y=132} (Button (ButtonSpec {width=78, height=19} False NoOp))
        , Control "Economics…" 'E' {x=7, y=162} (Button (ButtonSpec {width=84, height=19} False NoOp))
        , Control "Physics…" 'y' {x=7, y=192} (Button (ButtonSpec {width=70, height=19} False NoOp))
        , Control "Landscape…" 'L' {x=7, y=222} (Button (ButtonSpec {width=82, height=19} False (UpdateView (Modal Landscape))))
        , Control "Play Options…" 't' {x=7, y=252} (Button (ButtonSpec {width=98, height=19} False NoOp))
        , Control "Weapons…" 'W' {x=7, y=282} (Button (ButtonSpec {width=68, height=19} False NoOp))

        , Control "Players" 'P' {x=8, y=40}
          (Numeric (NumericSpec 2 10 1 None (\config -> config.playerCount) (\config n -> { config | playerCount = n })))

        , Control "Rounds" 'R' {x=8, y=70}
          (Numeric (NumericSpec 5 1000 5 None (\config -> config.roundCount) (\config n -> { config | roundCount = n })))
        ]
    )

updateWorld : MainMenuData -> World -> MainMenuData
updateWorld menuData world = { menuData | world = world }

toggleControlByKey : MainMenuData -> String -> MainMenuData
toggleControlByKey menuData key =
  let
    maybeLabel = List.head (Dict.keys (findItem defaultControls key))
  in
    case maybeLabel of
      Just label -> toggleControl menuData label Up
      Nothing -> menuData

toggleControl : MainMenuData -> String -> Direction -> MainMenuData
toggleControl menuData label direction =
    { menuData | controls = updateControls menuData.controls label direction }

updateControls : Dict String Control -> String -> Direction -> Dict String Control<commit_msg>re-order list elements to reflect actual position<commit_after>module Scorched.Model.MainMenu exposing (..)

import Dict exposing (Dict)

import Scorched.Model.Types exposing (..)
import Scorched.Model.Geometry exposing (Dimension)

import Scorched.Model.Sky as Sky
import Scorched.Model.World as World

import Scorched.Model.Helper as Helper

default : MainMenuData
default =
  { controls = defaultControls
  , world = World.empty
  }

defaultControls : Dict String Control
defaultControls =
  Dict.fromList
    (List.map
      (\control -> (control.label, control))
        [ Control "Start" 'S' {x=7, y=12} (Button (ButtonSpec {width=82, height=19} False NoOp))

        , Control "Players" 'P' {x=8, y=40}
          (Numeric (NumericSpec 2 10 1 None (\config -> config.playerCount) (\config n -> { config | playerCount = n })))

        , Control "Rounds" 'R' {x=8, y=70}
          (Numeric (NumericSpec 5 1000 5 None (\config -> config.roundCount) (\config n -> { config | roundCount = n })))

        , Control "Sound…" 'o' {x=7, y=102} (Button (ButtonSpec {width=56, height=19} False NoOp))
        , Control "Hardware…" 'H' {x=7, y=132} (Button (ButtonSpec {width=78, height=19} False NoOp))
        , Control "Economics…" 'E' {x=7, y=162} (Button (ButtonSpec {width=84, height=19} False NoOp))
        , Control "Physics…" 'y' {x=7, y=192} (Button (ButtonSpec {width=70, height=19} False NoOp))
        , Control "Landscape…" 'L' {x=7, y=222} (Button (ButtonSpec {width=82, height=19} False (UpdateView (Modal Landscape))))
        , Control "Play Options…" 't' {x=7, y=252} (Button (ButtonSpec {width=98, height=19} False NoOp))
        , Control "Weapons…" 'W' {x=7, y=282} (Button (ButtonSpec {width=68, height=19} False NoOp))
        ]
    )

updateWorld : MainMenuData -> World -> MainMenuData
updateWorld menuData world = { menuData | world = world }

toggleControlByKey : MainMenuData -> String -> MainMenuData
toggleControlByKey menuData key =
  let
    maybeLabel = List.head (Dict.keys (findItem defaultControls key))
  in
    case maybeLabel of
      Just label -> toggleControl menuData label Up
      Nothing -> menuData

toggleControl : MainMenuData -> String -> Direction -> MainMenuData
toggleControl menuData label direction =
    { menuData | controls = updateControls menuData.controls label direction }

updateControls : Dict String Control -> String -> Direction -> Dict String Control
{'fraction_non_alphanumeric': 0.13326381647549532, 'fraction_numerical': 0.03295099061522419, 'mean_word_length': 3.6608357628765793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3374605', 'n_tokens_mistral': 1614, 'n_tokens_neox': 1508, 'n_words': 465}