Skip to content

Commit

Permalink
Merge pull request #172 from CWolfs/develop
Browse files Browse the repository at this point in the history
v1.6.0
  • Loading branch information
CWolfs authored Jul 14, 2023
2 parents 5577843 + 82ab980 commit a32ffea
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 23 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,7 @@ defs/operations/set_battletech_camera_hard_lock.json
defs/operations/add_flashpoint.json

defs/operations/sideload_conversation.json

defs/operations/add_mech.json

defs/operations/evaluate_timeline.json
2 changes: 1 addition & 1 deletion ConverseTek.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<AssemblyName>ConverseTek</AssemblyName>
<ApplicationIcon>conversetek.ico</ApplicationIcon>
<Version>1.5.0</Version>
<Version>1.6.0</Version>
<Authors>Richard Griffiths</Authors>
<Copyright>Richard Griffiths</Copyright>
<StartupObject />
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "conversetek",
"version": "1.5.0",
"version": "1.6.0",
"description": "Conversation editor for Battletech",
"author": "Richard Griffiths [CWolf] ([email protected])",
"license": "GPL-3.0",
Expand Down
38 changes: 34 additions & 4 deletions app/src/components/EditableLogic/EditableLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,25 @@ function EditableLogic({ scope = 'all', category, logic, isEven = false, parentL
options={defStore.getPresetValuesForOptions(presetValue as string)}
onChange={(value) => {
if (typeof value === 'string') {
const parsedValue = tryParseInt(value, 0);
defStore.setArgValue(logic, arg, parsedValue);
if (value === '-') {
defStore.setArgValue(logic, arg, value);
} else {
const parsedValue = tryParseInt(value, 0);
if (isNaN(parsedValue)) {
defStore.setArgValue(logic, arg, 0);
} else {
defStore.setArgValue(logic, arg, parsedValue);
}
}
} else {
defStore.setArgValue(logic, arg, value as number);
}
}}
onBlur={(value) => {
if (value === '-') {
defStore.setArgValue(logic, arg, 0);
}
}}
optionLabelProp="value"
valueLabel={defStore.getPresetValue(presetValue as string, argVal)}
/>
Expand All @@ -224,12 +237,29 @@ function EditableLogic({ scope = 'all', category, logic, isEven = false, parentL
value={typeof argVal === 'number' ? argVal.toString() : argVal}
onChange={(value) => {
if (typeof value === 'string') {
const parsedValue = tryParseInt(value, 0);
defStore.setArgValue(logic, arg, parsedValue);
if (value === '' && valueProps.optionLabelProp != null && valueProps.options != null) {
defStore.setArgValue(logic, arg, value); // Let's autocomplete occur for ints/floats with text/value
} else {
if (value === '-') {
defStore.setArgValue(logic, arg, value);
} else {
const parsedValue = tryParseInt(value, 0);
if (isNaN(parsedValue)) {
defStore.setArgValue(logic, arg, 0);
} else {
defStore.setArgValue(logic, arg, parsedValue);
}
}
}
} else {
defStore.setArgValue(logic, arg, value as number);
}
}}
onBlur={(value) => {
if (value === '-') {
defStore.setArgValue(logic, arg, 0);
}
}}
{...valueProps}
/>
</section>
Expand Down
7 changes: 6 additions & 1 deletion app/src/components/EditbleInput/EditableInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ type Props = {
value: string | null;
options: ({ text: string; value: string | number } | string)[] | null;
onChange: (value: SelectValue) => void;
onBlur?: (value: SelectValue) => void;
optionLabelProp?: string | null;
valueLabel?: string | { text: string; value: string } | null;
};

function EditableInput({ value = null, options = null, onChange, optionLabelProp = null, valueLabel = null }: Props) {
function EditableInput({ value = null, options = null, onChange, onBlur, optionLabelProp = null, valueLabel = null }: Props) {
const isAutocomplete = !!options;
let displayValueLabel: string | { text: string; value: string | number } | null = valueLabel;
const conditionalProps: {
Expand Down Expand Up @@ -72,6 +73,7 @@ function EditableInput({ value = null, options = null, onChange, optionLabelProp
return false;
}}
onChange={onChange}
onBlur={onBlur}
/>
{optionLabelProp && (
<span style={valueLabelStyle}>
Expand All @@ -89,6 +91,9 @@ function EditableInput({ value = null, options = null, onChange, optionLabelProp
onChange={(event) => {
onChange(event.target.value);
}}
onBlur={(event) => {
onBlur?.(event.target.value);
}}
/>
);
}
Expand Down
18 changes: 10 additions & 8 deletions app/src/components/FileTree/FileTree.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable function-paren-newline */
import React from 'react';
import React, { CSSProperties } from 'react';
import { Tree } from 'antd';
import CustomScroll from 'react-custom-scroll';
import classnames from 'classnames';
Expand Down Expand Up @@ -31,19 +31,21 @@ function renderTreeNodes(dataStore: DataStore, data: { key: string; label: strin
if (data)
return data.map((item) => {
const { key } = item;
let label: string | JSX.Element = item.label;
let style: CSSProperties = { visibility: 'hidden' };

if (conversationAsset != null && key === getId(conversationAsset.conversation)) {
if (isConversationDirty) {
label = (
<span>
{`${item.label} `}
<span style={{ color: 'gold' }}>*</span>
</span>
);
style = { visibility: 'visible', color: 'gold' };
}
}

const label = (
<span>
{`${item.label} `}
<span style={style}>*</span>
</span>
);

return <TreeNode className="file-tree__tree__conversation" key={item.key} title={label} />;
});
return undefined;
Expand Down
11 changes: 7 additions & 4 deletions app/src/components/ViewableLogic/ViewableLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ function ViewableLogic({ logic }: Props) {

const { value: valueFromArg } = argValue;
let displayValue = valueFromArg;
if (viewLabel) {

if (viewLabel != null) {
if (viewLabel.includes('{value}')) {
if (!displayValue) {
return displayValue;
}
displayValue = viewLabel.replace('{value}', displayValue.toString());
} else {
displayValue = viewLabel;
displayValue = viewLabel.trim();
}
}

Expand All @@ -73,12 +74,14 @@ function ViewableLogic({ logic }: Props) {

if (inputVal) {
displayValue = inputVal.text;
if (inputVal.viewLabel) {

if (inputVal.viewLabel != null) {
const inputValueViewLabel = inputVal.viewLabel;

if (inputValueViewLabel.includes('{value}')) {
displayValue = inputValueViewLabel.replace('{value}', displayValue);
} else {
displayValue = inputVal.viewLabel;
displayValue = inputVal.viewLabel.trim();
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/stores/nodeStore/node-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ class NodeStore {
* =============================
*/
scrollToActiveNode(fallbackToPrevious = false) {
console.log('scroll to active node with fallback. fallbackToPrevious: ', fallbackToPrevious);
let focusNodeId = this.getActiveNodeId();
console.log('focusNodeId: ', focusNodeId);

if (focusNodeId == null && !fallbackToPrevious) return;

Expand Down
3 changes: 1 addition & 2 deletions defs/operations/set_battletech_string.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"view": ["inputs"],
"scope": "action",
"category": "primary",
"tooltip": "WARNING: This vanilla method is bugged. Set flashpoint DOESN'T WORK. It actually sets 'Current System' instead.",
"inputs": [
{
"label": "Type",
Expand All @@ -13,7 +12,7 @@
{ "viewlabel": "Set company stat", "text": "Company Stats", "value": 1 },
{ "viewlabel": "Set commander stat", "text": "Commander Stats", "value": 2 },
{ "viewlabel": "Set current system stat", "text": "Current System Stats", "value": 3 },
{ "viewlabel": "Set flashpoint stat", "text": "Flashpoint Stats - BUGGED", "value": 4 }
{ "viewlabel": "Set flashpoint stat", "text": "Flashpoint Stats", "value": 4 }
]
},
{
Expand Down

0 comments on commit a32ffea

Please sign in to comment.