Skip to content

Commit

Permalink
minor bugs & am missing warn
Browse files Browse the repository at this point in the history
  • Loading branch information
mathis committed Oct 9, 2023
1 parent 8ea6ce7 commit ed53079
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
6 changes: 5 additions & 1 deletion client/src/server/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,13 @@ export class History {

send(pkt: SendPacket<SendKey>) {
if (isRequest(pkt)) {
const rev = reverse(get(map), pkt)
if (rev === null)
return

const pending: Operation = {
forward: [pkt.type, pkt.content],
reverse: reverse(get(map), pkt)
reverse: rev,
}
this.pending.push(pending)

Expand Down
23 changes: 17 additions & 6 deletions client/src/ui/lib/editLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import ImagePicker from './imagePicker.svelte'
import AutomapperPicker from './automapper.svelte'
// import { automap, parse, type Config as AutomapperConfig } from '../../twmap/automap'
import { ComposedModal, ModalBody, ModalHeader } from 'carbon-components-svelte'
import { ComposedModal, ModalBody, ModalHeader, TooltipIcon } from 'carbon-components-svelte'
import { WarningAlt } from 'carbon-icons-svelte'
import { rmap } from '../global'
import { bytesToBase64, resIndexToString, stringToResIndex } from '../../server/convert'
import { pick, read, sync, _ } from '../../server/util'
Expand Down Expand Up @@ -73,8 +74,12 @@
}
}
function amCfgName(img: string, cfg: number): string {
return $automappers[img + '.rules']?.configs?.at(cfg) ?? 'None'
function amCfgName(img: string, cfg: number | null): string {
if (cfg === null) {
return 'None'
} else {
return $automappers[img + '.rules']?.configs?.at(cfg) ?? `#${cfg} (missing)`
}
}
let imagePickerOpen = false
Expand Down Expand Up @@ -238,7 +243,7 @@
apply: () => $rmap.map.images,
}])
$: if (layer && layer instanceof TilesLayer) {
syncAmCfg = read($server, layer.automapper.config, {
syncAmCfg = read($server, layer.automapper.config === -1 ? null : layer.automapper.config, {
query: 'edit/layer',
match: [g, l, { automapper_config: { config: pick } }],
})
Expand Down Expand Up @@ -336,7 +341,13 @@
</label>
<Number label="Color Env. Offset" integer bind:value={$syncColorEnvOff} />
<label>
Automapper <input type="button" value={amCfgName($syncImg?.name, $syncAmCfg)} disabled={layer.image === null} on:click={() => automapperOpen = true} />
<span>
{#if $syncAmCfg !== null && $automappers[$syncImg?.name + '.rules'] === undefined}
<TooltipIcon tooltipText="The rules file is missing. Upload or create one." icon={WarningAlt} direction="bottom" align="start" />
{/if}
Automapper
</span>
<input type="button" value={amCfgName($syncImg?.name, $syncAmCfg)} disabled={$syncImg === null} on:click={() => automapperOpen = true} />
</label>
<ComposedModal bind:open={automapperOpen} size="sm" selectorPrimaryFocus=".bx--modal-close">
<ModalHeader title="Automapper" />
Expand All @@ -347,7 +358,7 @@
/>
</ModalBody>
</ComposedModal>
<button class="default" disabled={$syncAmCfg === null} on:click={onAutomap}>Apply Automapper</button>
<button class="default" disabled={$syncAmCfg === null || $syncImg === null} on:click={onAutomap}>Apply Automapper</button>
{/if}
{#if layer instanceof TilesLayer || layer instanceof QuadsLayer}
<label>
Expand Down
8 changes: 7 additions & 1 deletion client/styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ $header-h: 3rem;
align-items: center;
width: 100%;
gap: 1rem;

span {
display: flex;
align-items: center;
gap: .5rem;
}
}

input[type='number'] {
Expand Down Expand Up @@ -1040,4 +1046,4 @@ textarea.diagnostics {
z-index: 7000;
margin: 1rem;
}
}
}
Binary file modified rules++/rpp
Binary file not shown.
8 changes: 5 additions & 3 deletions server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,10 @@ impl Server {
String::from_utf8_lossy(&exec.stderr).into_owned(),
))
}
None => Err(Error::ServerError("rpp: no exit status".into())),
None => {
log::error!("rpp: {}", String::from_utf8_lossy(&exec.stderr));
Err(Error::ServerError("rpp: no exit status".into()))
}
}
}

Expand Down Expand Up @@ -1406,8 +1409,7 @@ impl Server {
if let twmap::Layer::Tiles(layer) = layer {
let mut am_path = room.automapper_path();
am_path.push(format!("{image_name}.rules"));
let file = std::fs::read_to_string(am_path)
.map_err(|e| Error::ServerError(e.to_string().into()))?;
let file = std::fs::read_to_string(am_path).map_err(|_| Error::AutomapperNotFound)?;
let automapper = twmap::automapper::Automapper::parse(image_name, &file)
.map_err(|e| Error::AutomapperError(e.to_string()))?;
layer
Expand Down

0 comments on commit ed53079

Please sign in to comment.