Skip to content

Commit

Permalink
chore: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lsdrfrx committed Oct 15, 2024
0 parents commit 374a69a
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
*.log
skylinux.cfg
*~
1 change: 1 addition & 0 deletions nim.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-d:release
14 changes: 14 additions & 0 deletions skylinux.nimble
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Package

version = "1.0"
author = "Christian Guetnga"
description = "Skyrim Mod Manager for Linux nords"
license = "MIT"
srcDir = "src"
binDir = "bin"
bin = @["skylinux"]


# Dependencies

requires "nim >= 2.0.8"
39 changes: 39 additions & 0 deletions src/config.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
import parsecfg
import logging

import constants

type Config* = object
gamePath*: string
winePrefixPath*: string
modsPath*: string
modLoadOrderPath*: string

proc createConfigFile(): Config =
info("config file does not exists. Creating a new one")

var dict = newConfig()
result = Config()

stdout.write("Enter game path: ")
let gamePath = stdin.readLine()

stdout.write("Enter .wine prefix path: ")
let winePrefixPath = stdin.readLine()

result.gamePath = gamePath
result.winePrefixPath = winePrefixPath

dict.setSectionKey("General", "game_path", gamePath)
dict.setSectionKey("General", "wine_prefix_path", winePrefixPath)

dict.writeConfig(cfgPath)

proc loadConfigFile(): Config =
let dict = loadConfig(cfgPath)
result.gamePath = dict.getSectionValue("General", "game_path")
result.winePrefixPath = dict.getSectionValue("General", "wine_prefix_path")

proc getConfig*(): Config =
if not fileExists(cfgPath): createConfigFile() else: loadConfigFile()
5 changes: 5 additions & 0 deletions src/constants.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const cfgPath* = "./skylinux.cfg"
const logPath* = "./skylinux.log"
const errLogPath* = "./skylinux_errors.log"

const logFmtStr* = "[$time $date] - $levelname: "
7 changes: 7 additions & 0 deletions src/logger.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import logging
import constants

proc loggerInit*() {.noreturn.} =
addHandler newConsoleLogger(fmtStr=logFmtStr)
addHandler newFileLogger(logPath, fmtStr=logFmtStr)
addHandler newFileLogger(errLogPath, fmtStr=logFmtStr, levelThreshold=lvlError)
16 changes: 16 additions & 0 deletions src/skylinux.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import strformat

import logger
import config

# Logger setup
loggerInit()

proc getMods(): seq[string] =
@[]

proc runGame(config: Config, withModes: bool = true) {.noreturn.} =
discard execShellCmd(fmt"cd {config.gamePath} && wine skse_loader.exe")

var cfg = getConfig()

0 comments on commit 374a69a

Please sign in to comment.