Skip to content

Commit

Permalink
fix hash autocomplete
Browse files Browse the repository at this point in the history
- begin device from template
  • Loading branch information
Ryex committed Mar 30, 2024
1 parent 78463e6 commit d9a8a9f
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 23 deletions.
1 change: 0 additions & 1 deletion ic10emu/data/Enums.json

This file was deleted.

78 changes: 76 additions & 2 deletions ic10emu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@ pub enum VMError {
InvalidNetwork(u16),
}

#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum FieldType {
Read,
Write,
ReadWrite,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LogicField {
pub field_type: FieldType,
pub value: f64,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct Slot {
pub typ: SlotType,
pub fields: HashMap<grammar::SlotLogicType, LogicField>,
}

Expand All @@ -57,6 +58,79 @@ pub enum Connection {
Other,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct DeviceTemplate {
pub name: Option<String>,
pub hash: Option<i32>,
pub logic: HashMap<grammar::LogicType, LogicField>,
pub slots: Vec<SlotTemplate>,
pub slotlogic: HashMap<grammar::LogicType, usize>,
pub conn: HashMap<u32, Connection>,
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ConnectionType {
Chute,
Pipe,
Power,
PowerData,
#[default]
Data,
}

impl From<ConnectionType> for Connection {
fn from(value: ConnectionType) -> Self {
match value {
ConnectionType::Chute | ConnectionType::Pipe | ConnectionType::Power => Self::Other,
_ => Self::CableNetwork(None),
}
}
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum SlotType {
AccessCard,
Appliance,
Back,
Battery,
Blocked,
Bottle,
Cartridge,
Circuitboard,
CreditCard,
DataDisk,
DrillHead,
Egg,
Entity,
Flare,
GasCanister,
GasFilter,
Helmet,
Ingot,
LiquidBottle,
LiquidCanister,
Magazine,
Ore,
Organ,
Plant,
ProgramableChip,
ScanningHead,
SensorProcessingUnit,
SoundCartridge,
Suit,
Tool,
Torpedo,
#[default]
#[serde(other)]
None,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct SlotTemplate {
pub name: String,
pub typ: SlotType,
}

#[derive(Debug, Default)]
pub struct Device {
pub id: u16,
Expand Down
4 changes: 2 additions & 2 deletions ic10lsp_wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ic10lsp_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ wasm-bindgen-futures = { version = "0.4.30", features = ["futures-core-03-stream
wasm-streams = "0.4"
# web-tree-sitter-sys = "1.3"
ic10lsp = { git = "https://github.com/Ryex/ic10lsp.git", branch = "wasm" }
# ic10lsp = { path = "../../ic10lsp" }

[profile.release]
# Tell `rustc` to optimize for small code size.
Expand Down
4 changes: 4 additions & 0 deletions www/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"jetpack",
"Keybind",
"lbns",
"logicable",
"logictype",
"logictypes",
"Mineables",
Expand All @@ -71,6 +72,7 @@
"offcanvas",
"overcolumn",
"Overlength",
"pedia",
"popperjs",
"preproc",
"putd",
Expand All @@ -87,6 +89,8 @@
"sgez",
"sgtz",
"slez",
"slotlogic",
"slotlogicable",
"slotlogictype",
"slotlogictypes",
"slottype",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions www/data/database.json

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions www/src/scss/dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ body {
}

.ace_tooltip {
background-color: #343a40;
color: #dee2e6;
background: #282c34;
color: #c1c1c1;
border: 1px #484747 solid;
box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);
}

.ace_tooltip.ace_dark {
background: #282c34;
color: #c1c1c1;
border: 1px #484747 solid;
box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);
}

.ace_status-indicator {
Expand Down Expand Up @@ -285,7 +294,13 @@ body {
* --------------- */

code {
color: #e685b5
// color: #e685b5
color: #c678dd;
}

.ace_tooltip code {
font-style: italic;
font-size: 12px;
}

.navbar-default .navbar-nav>li>a {
Expand Down
17 changes: 2 additions & 15 deletions ic10emu/stationpedia.py → www/stationpedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,11 @@
import re
import json


def extract_logicable():
logicable = []
pedia = {}
with Path("./Stationpedia.json").open("r") as f:
pedia.update(json.load(f))
for page in pedia["pages"]:
if page["LogicInsert"] or page["LogicSlotInsert"]:
logicable.append(page)
# print(f"{len(logicable)} of {len(pedia["pages"])} are logicable")
return logicable


def extract_all():
items = {}
pedia = {}
linkPat = re.compile(r"<link=\w+><color=[\w#]+>(.+?)</color></link>")
with Path("./Stationpedia.json").open("r") as f:
with (Path("data") / "Stationpedia.json").open("r") as f:
pedia.update(json.load(f))
for page in pedia["pages"]:
item = defaultdict(list)
Expand Down Expand Up @@ -110,7 +97,7 @@ def extract_all():
if item["logic"] is not None and item["conn"] is not None
]

with open("database.json", "w") as f:
with open("data/database.json", "w") as f:
json.encoder
json.dump(
{
Expand Down

0 comments on commit d9a8a9f

Please sign in to comment.