Skip to content

Commit

Permalink
Added welcome message on the first extension use #47
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Jul 19, 2024
1 parent 167763c commit e4e592b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
26 changes: 26 additions & 0 deletions editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import * as providers from './providers';
import * as lc from './lsp/lang_client';
import * as state from './state';
import { getContextKeys } from './context_keys';
import { getPersistence } from './persistence';


export function activate(context: vscode.ExtensionContext) {
const cfg = config.getConfiguration();
const ctxKeys = getContextKeys();
const db = getPersistence(context);

ctxKeys.debugFeaturesEnabled = cfg.enableDebugFeatures;
ctxKeys.languageServerActive = false;
Expand All @@ -25,6 +27,30 @@ export function activate(context: vscode.ExtensionContext) {
ctxKeys.languageServerActive = true;
});
}

if (db.shouldSeeWelcomeMessage) {
enum Answer {
ShowTuto = "Show tutorial",
Skip = "I know what I'm doing"
}

vscode.window.showInformationMessage(
"Thank you for installing WitcherScript IDE!\nCheck out the tutorial to get started.",
Answer.ShowTuto, Answer.Skip,
).then((answer) => {
if (answer) {
switch (answer) {
case Answer.ShowTuto:
vscode.commands.executeCommand("workbench.action.openWalkthrough", "SpontanCombust.witcherscript-ide#witcherscript-ide.walkthrough", false);
break;
case Answer.Skip:
break;
}

db.shouldSeeWelcomeMessage = false;
}
});
}
}

export function deactivate(): Thenable<void> | undefined {
Expand Down
9 changes: 9 additions & 0 deletions editors/vscode/src/persistence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ export class Persistence {
set neverShowAgainForeignScriptWarning(value: boolean) {
this.ctx.globalState.update("NeverShowAgainForeignScriptWarning", value)
}


get shouldSeeWelcomeMessage(): boolean {
return this.ctx.globalState.get<boolean>("ShouldSeeWelcomeMessage") ?? true;
}

set shouldSeeWelcomeMessage(value: boolean) {
this.ctx.globalState.update("ShouldSeeWelcomeMessage", value)
}
}

export interface OpenManifestOnInit {
Expand Down

0 comments on commit e4e592b

Please sign in to comment.