Skip to content

Instantly share code, notes, and snippets.

@stenno
Last active February 6, 2019 00:52
Show Gist options
  • Save stenno/da1dca6941c1c8174c972e4113b608d7 to your computer and use it in GitHub Desktop.
Save stenno/da1dca6941c1c8174c972e4113b608d7 to your computer and use it in GitHub Desktop.
NetHack tty windows
const coreTTYWindows = [{
name: "message",
internalName: "NHW_MESSAGE",
id: windowIds.NHW_MESSAGE,
description: "Message window, 1 line long, very wide, top of screen",
resize: (baseDimensions) => {
return { rows: msgHistory, cols: 0, maxRows: 0, maxCols: 0 }
}
}, {
name: "status",
internalName: "NHW_STATUS",
id: windowIds.NHW_STATUS,
description: "Status window, 2 lines long, full width, bottom of screen",
resize: (baseDimensions) => {
const { cols } = baseDimensions;
return { rows: 2, cols, maxRows: 2, maxCols: cols };
}
}, {
name: "map",
internalName: "NHW_MAP",
id: windowIds.NHW_MAP,
description: "Map window, ROWNO lines long, full width, below message window",
resize: (baseDimensions) => {
const { rowno, colno } = baseDimensions;
return { rows: rowno, cols: colno, maxRows: 0, maxCols: 0 };
}
}, {
name: "menu",
internalName: "NHW_MENU",
id: windowIds.NHW_MENU,
description: "Inventory/menu window, variable length, full width, top of screen",
resize: (baseDimensions) => {
const { cols } = baseDimensions;
return { rows: 0, cols, maxRows: 0, maxCols: 0 };
}
}, {
name: "text",
internalName: "NHW_TEXT",
id: windowIds.NHW_TEXT,
description: "Help window, the same, different semantics for display, etc",
resize: (baseDimensions) => {
const { cols } = baseDimensions;
return { rows: 0, cols, maxRows: 0, maxCols: 0 };
}
}, {
name: "base",
internalName: "NHW_BASE",
id: windowIds.NHW_BASE,
description: "Base window, used for absolute movement on the screen",
resize: (baseDimensions) => {
const { rows, cols } = baseDimensions;
return { rows, cols, maxRows: 0, maxCols: 0 };
}
},
];
const createNHWindow = (baseDimensions, coreTTYWindow, offset, data) => {
const { id, name, resize } = coreTTYWindow;
return { id, name, offset, data, dimensions: resize(baseDimensions) };
};
const initializeNHWindows = (baseDimensions) => {
const initialOffset = { x: 0, y: 0 };
const initialData = [];
return coreTTYWindows.map(coreWindow => createNHWindow(baseDimensions, coreWindow, initialOffset, initialData));
};
const mockupDimensions = {
rows: 24,
cols: 80,
rowno: 21,
colno: 80
};
const initializedWindows = initializeNHWindows(mockupDimensions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment