Skip to content

Commit

Permalink
Merge pull request #8 from decentraland-scenes/html-tag-fix
Browse files Browse the repository at this point in the history
bug: html tag fix
  • Loading branch information
wacaine committed Jun 16, 2023
2 parents 278b488 + c3d092c commit 7dc61db
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 32 additions & 1 deletion src/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,4 +627,35 @@ export function getImageAtlasMapping(data?: ImageAtlasData): number[] {
}
return 0
}




export function closeTag(dialogData:any, newChars: number){
if(dialogData.visibleChars == 0 || newChars ==0 ) return

let openTag: boolean = false
let closeTag : boolean = false
for(let i = dialogData.visibleChars-newChars; i < dialogData.visibleChars ; i++){

if(!openTag){
if(dialogData.fullText.substr(i, 1) == '<'){
openTag= true

}
} else {
if(dialogData.fullText.substr(i, 1) == '>'){
closeTag= true

}
}
}

if(!openTag || closeTag){
return
}

while(dialogData.visibleChars < dialogData.fullText.length && dialogData.fullText.substr(dialogData.visibleChars-1, 1) != '>'){
dialogData.visibleChars+=1
}
return
}
4 changes: 3 additions & 1 deletion src/systems.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Entity, InputAction, PointerEventType, TextShape, Transform, engine, inputSystem } from "@dcl/sdk/ecs";
import { IsFollowingPath, IsTypingBubble, IsTypingDialog, TrackUserFlag } from "./components";
import { activeNPC, walkingTimers } from "./npc";
import { ConfirmMode, confirmText, npcDialogComponent, rushText, skipDialogs } from "./dialog";
import { ConfirmMode, closeTag, confirmText, npcDialogComponent, rushText, skipDialogs } from "./dialog";
import { bubbles, next } from "./bubble";
import { Quaternion, Vector3 } from "@dcl/sdk/math";

Expand Down Expand Up @@ -31,6 +31,8 @@ export function handleDialogTyping(dt:number) {
dialogData.timer = 0

dialogData.visibleChars += charsToAdd
closeTag(dialogData, charsToAdd)


if (dialogData.visibleChars >= dialogData.fullText.length) {
dialogData.typing = false
Expand Down

0 comments on commit 7dc61db

Please sign in to comment.