Skip to content

Commit

Permalink
Add borders around countries in galaxy map (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasdoehne authored Dec 4, 2022
1 parent e955596 commit 3b654bd
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 91 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ matplotlib==3.6.0
networkx==2.8.6
numpy==1.23.3
packaging==21.3
Pillow==9.2.0
Pillow==9.3.0
plotly==5.10.0
pyparsing==3.0.9
python-dateutil==2.8.2
Expand Down
38 changes: 29 additions & 9 deletions stellarisdashboard/config.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import dataclasses
import itertools
import logging
import multiprocessing
import multiprocessing as mp # only to get the cpu count
import pathlib
import platform
import sys
import traceback
from collections import defaultdict
from typing import List, Dict, Any

import yaml

LOG_LEVELS = {"CRITICAL": logging.CRITICAL, "ERROR": logging.ERROR, "WARNING": logging.WARNING, "INFO": logging.INFO, "DEBUG": logging.DEBUG}
CPU_COUNT = mp.cpu_count()

LOG_FORMAT = logging.Formatter("%(processName)s - %(asctime)s - %(name)s - %(levelname)s - %(message)s")
LOG_FORMAT = logging.Formatter(
"%(processName)s - %(asctime)s - %(name)s - %(levelname)s - %(message)s"
)

CONFIG: "Config" = None
logger: logging.Logger = None
Expand Down Expand Up @@ -136,7 +138,11 @@ def _get_default_base_output_path():
"research_output_by_category_graph",
],
"Military": ["fleet_size_graph", "military_power_graph", "fleet_composition_graph"],
"Victory": ["victory_rank_graph", "victory_score_graph", "victory_economy_score_graph",],
"Victory": [
"victory_rank_graph",
"victory_score_graph",
"victory_economy_score_graph",
],
MARKET_TAB: [], # filled dynamically based on resource config
}
DEFAULT_MARKET_RESOURCES = [
Expand Down Expand Up @@ -178,6 +184,7 @@ def _get_default_base_output_path():
polling_interval=0.5,
check_version=True,
log_level="INFO",
include_id_in_names=True, # TODO handle duplicate keys in legend entries in a better way
show_everything=False,
filter_events_by_type=True,
show_all_country_types=False,
Expand Down Expand Up @@ -217,6 +224,7 @@ class Config:
show_everything: bool = None
read_all_countries: bool = None
show_all_country_types: bool = None
include_id_in_names: bool = None

save_name_filter: str = None
skip_saves: int = None
Expand All @@ -241,6 +249,7 @@ class Config:
"read_all_countries",
"show_all_country_types",
"log_to_file",
"include_id_in_names",
}
INT_KEYS = {
"port",
Expand All @@ -263,7 +272,9 @@ class Config:
"tab_layout",
}
LIST_KEYS = {"market_resources", "market_fee"}
ALL_KEYS = PATH_KEYS | BOOL_KEYS | INT_KEYS | FLOAT_KEYS | STR_KEYS | DICT_KEYS | LIST_KEYS
ALL_KEYS = (
PATH_KEYS | BOOL_KEYS | INT_KEYS | FLOAT_KEYS | STR_KEYS | DICT_KEYS | LIST_KEYS
)

def apply_dict(self, settings_dict):
logger.info("Updating settings")
Expand Down Expand Up @@ -303,7 +314,9 @@ def _process_path_keys(self, key, val):
)
return
except Exception:
logger.warning(f"Error during path creation while updating {key} with value {val}:")
logger.warning(
f"Error during path creation while updating {key} with value {val}:"
)
logger.error(traceback.format_exc())
logger.info(f"Ignoring setting {key} with value {val}.")
return
Expand All @@ -321,7 +334,9 @@ def _preprocess_tab_layout(self, settings_dict):
logger.warning(f"Ignoring tab {tab}, it is reserved for the galaxy map")
continue
if tab == MARKET_TAB:
logger.warning(f"Ignoring values for tab {tab}, it is filled dynamically")
logger.warning(
f"Ignoring values for tab {tab}, it is filled dynamically"
)
processed[tab] = []
continue
if not isinstance(plot_list, list):
Expand Down Expand Up @@ -373,7 +388,9 @@ def _preprocess_bool(self, val):
return True
elif val == "false":
return False
raise ValueError(f"Expected either true or false for bool value, received {val}.")
raise ValueError(
f"Expected either true or false for bool value, received {val}."
)

@property
def db_path(self) -> pathlib.Path:
Expand All @@ -386,10 +403,13 @@ def db_path(self) -> pathlib.Path:
def localization_files(self):
files = list(
itertools.chain(
self.localization_file_dir.glob("**/*.yaml"), self.localization_file_dir.glob("**/*.yml"),
self.localization_file_dir.glob("**/*.yaml"),
self.localization_file_dir.glob("**/*.yml"),
)
)
logger.info(f"Loaded {len(files)} localization files from {self.localization_file_dir}")
logger.info(
f"Loaded {len(files)} localization files from {self.localization_file_dir}"
)
return files


Expand Down
Loading

0 comments on commit 3b654bd

Please sign in to comment.