Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Journal Viewer
- ;
- ;
- ; DejaVu fonts:
- ; https://sourceforge.net/projects/dejavu/
- ;
- ; 1. Download und extract the archive.
- ; 2. Open the "ttf" folder.
- ; 3. Install "DejaVuSansMono.ttf" and "DejaVuSansMono-Bold.ttf".
- ; (Right-click the files and select "Install".)
- ;
- ;========================================
- ;USER SETTINGS
- set #lpc 100
- ;window
- set %windowWidth 750
- set %windowHeight 800
- set %windowTitle Journal , #spc , Viewer
- set %fontName DejaVu , #spc , Sans , #spc , Mono
- ;list
- set %listBackgroundColor $222827
- set %listFontColor $2EE2A6
- set %listFontName DejaVu , #spc , Sans , #spc , Mono
- set %listFontSize 12
- set %listFontStyle b
- set %maxLineLength 70
- set %indentLength 16
- sub formatMessage
- ; %1: index, %2: time, %3: channel, %4: name, %5: text, %6: jindex
- return %2 , #spc , [ , %3 , ] , #spc , < , %4 , > , #spc , %5 , #spc ; , ( , %6 , )
- ;========================================
- ;MISC SETTINGS
- ;list
- set %listX 2
- set %listY 24
- set %listWidth %windowWidth - %listX - 2
- set %listHeight %windowHeight - %listY - 2
- ;channel checkboxes
- set %checkboxWidth 80
- set %checkboxSpacing 10
- ;channels
- set %channel_1 g
- set %channel_2 a
- set %channel_3 c
- set %channel_4 t
- set %channel_count 4
- set %channelTitle_1 Guild
- set %channelTitle_2 Alliance
- set %channelTitle_3 Public
- set %channelTitle_4 Trade
- set %tag_new G
- set %tag_guild G
- set %tag_alliance A
- set %tag_public C
- set %tag_trade T
- ;========================================
- ;INIT
- set #menubutton N/A
- set %indentString #dot
- for %i 2 %indentLength
- {
- set %indentString %indentString , #spc
- }
- if *journalViewer_activeChannels = N/A
- set *journalViewer_activeChannels gact
- set %message_count 0
- set %line_count 0
- set %flagRedrawList #false
- set %flagDisableRedrawing #false
- set %flagSaveLog #false
- set %jStart #jindex + 1
- gosub drawWindow
- ;event sysmessage [public][TestString]: 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J
- ;========================================
- ;MAIN loop
- while #true
- {
- if #menubutton = closed
- halt
- gosub scanJournalLoop
- gosub updateActiveChannels
- gosub mgetDisableRedrawing
- if %flagRedrawList && ! %flagDisableRedrawing
- gosub redrawList
- }
- halt
- ;========================================
- ;SUBS
- sub scanJournalLoop
- if #jindex >= %jStart
- {
- set %jEnd #jIndex
- for %ji %jStart %jEnd
- {
- str ins #time : 3
- str ins #strRes : 6
- set %tmpTime #strRes
- scanjournal %ji
- set %journalEntry #journal
- str left %journalEntry 1
- set %firstChar #strres
- if %firstChar notin [<
- continue
- if %firstChar = <
- {
- set %nameOffset 0
- set %closingBracket >
- }
- else
- {
- set %nameOffset 1
- set %closingBracket ]
- }
- str pos %journalEntry %closingBracket
- set %posClosingBracket #strRes
- if %posClosingBracket < 3
- continue
- set %tmpTagLength %posClosingBracket - 2
- str mid %journalEntry 2 %tmpTagLength
- set %tmpTag #strRes
- set %tmpChannel %tag_ . %tmpTag
- if %tmpChannel = N/A
- continue
- str pos %journalEntry :
- set %posColon #strRes
- if %posColon < %posClosingBracket + 3 + %nameOffset
- continue
- set %nameStart %posClosingBracket + 2
- set %nameLength %posColon - %nameStart - %nameOffset
- str mid %journalEntry %nameStart %nameLength
- set %tmpName #strRes
- set %deleteCharacters %posColon + 1
- str del %journalEntry 1 %deleteCharacters
- set %tmpMessageText #strRes
- spcLoop:
- str pos %tmpMessageText _
- set %posUnderscore #strRes
- if %posUnderscore > 0
- {
- str del %tmpMessageText %posUnderscore 1
- str ins #strRes #spc %posUnderscore
- set %tmpMessageText #strRes
- goto spcLoop
- }
- set %message_count %message_count + 1
- set %messageChannel_ . %message_count %tmpChannel
- set %messageTime_ . %message_count %tmpTime
- set %messageName_ . %message_count %tmpName
- set %messageText_ . %message_count %tmpMessageText
- set %messageJindex_ . %message_count %ji
- gosub formatMessage %message_count %tmpTime %tmpChannel %tmpName %tmpMessageText %ji
- set %messageString_ . %message_count #result
- if %flagSaveLog = #true
- {
- gosub escapeSpecialCharacters #result
- execute cmd.exe /c "echo , #spc , #result , #spc , >> journal.log"
- }
- gosub addMessageToList %message_count
- }
- set %jStart %jEnd + 1
- }
- return
- sub addMessageToList ; %1 = message index
- set %tmpLineChannel %messageChannel_ . %1
- set %tmpMessageString %messageString_ . %1
- str len %tmpMessageString
- set %messageLength #strRes
- set %row_i 0
- set %substrStart 1
- while %substrStart <= %messageLength
- {
- set %row_i %row_i + 1
- if %row_i = 1
- {
- set %substrLength %maxLineLength
- set %tmpLineString
- }
- else
- {
- set %substrLength %maxLineLength - %indentLength
- set %tmpLineString %indentString
- }
- str mid %tmpMessageString %substrStart %substrLength
- set %substr #strRes
- if %substrStart + %substrLength <= %messageLength
- {
- str count %substr #spc
- if #strRes > 0
- {
- str pos %substr #spc #strRes
- set %substrLength #strRes
- str left %substr #strRes
- set %substr #strRes
- }
- }
- trimLoop:
- str left %substr 1
- if #strRes = #spc
- {
- str del %substr 1 1
- set %substr #strRes
- goto trimLoop
- }
- set %tmpLineString %tmpLineString , %substr
- set %tmpRow_ . %row_i %tmpLineString
- set %substrStart %substrStart + %substrLength
- }
- set %tmpRow_count %row_i
- for %row_i %tmpRow_count 1
- {
- set %tmpLineIndex %line_count + %tmpRow_count - %row_i + 1
- set %tmpLineString %tmpRow_ . %row_i
- set %lineChannel_ . %tmpLineIndex %tmpLineChannel
- set %lineString_ . %tmpLineIndex %tmpLineString
- }
- set %line_count %line_count + %tmpRow_count
- if %tmpLineChannel in *journalViewer_activeChannels
- set %flagRedrawList #true
- return
- sub drawWindow
- menu Font Name %fontName
- menu Clear
- menu Window Title %windowTitle
- menu Window Size %windowWidth %windowHeight
- menu Show
- gosub drawCheckboxes
- ;list settings
- menu Font Transparent #true
- menu Font Align Right
- menu Font Name %listFontName
- menu Font Size %listFontSize
- menu Font Style %listFontStyle
- menu Font Color %listFontColor
- menu Font BGColor %listBackgroundColor
- ;dummy list
- menu List Create dummyList %listX %listY %listWidth %listHeight
- return
- sub drawCheckboxes
- ; 43, 60, 50, 45, 116
- for %chi 1 %channel_count
- {
- set %tmpChk_i %channel_ . %chi
- set %tmpChkName chk_ , %tmpChk_i
- set %tmpChkTitle %channelTitle_ . %chi
- set %tmpChkX 2 + ( %chi - 1 ) * ( %checkboxWidth + %checkboxSpacing )
- set %tmpChkActive %tmpChk_i in *journalViewer_activeChannels
- menu check %tmpChkName %tmpChkX 2 %checkboxWidth 20 %tmpChkActive %tmpChkTitle
- }
- set %tmpChkX %windowWidth - 130
- menu check chk_disableRedrawing %tmpChkX 2 120 20 #false disable redrawing
- return
- sub redrawList
- menu delete journal
- menu List Create journal %listX %listY %listWidth %listHeight
- if %line_count > 0
- {
- for %lineIndex %line_count 1
- {
- if %lineChannel_ . %lineIndex in *journalViewer_activeChannels
- {
- menu list add journal %lineString_ . %lineIndex
- }
- }
- }
- set %flagRedrawList #false
- return
- sub updateActiveChannels
- set %tmpActiveChannels
- for %ci 1 %channel_count
- {
- set %chk_i %channel_ . %ci
- menu get chk_ , %chk_i
- if #menuRes = #true
- {
- set %tmpActiveChannels %tmpActiveChannels , %chk_i
- }
- }
- if *journalViewer_activeChannels <> %tmpActiveChannels
- {
- set *journalViewer_activeChannels %tmpActiveChannels
- set %flagRedrawList #true
- }
- return
- sub mgetDisableRedrawing
- menu get chk_disableRedrawing
- if %flagDisableRedrawing && ! #menuRes
- set %flagRedrawList #true
- set %flagDisableRedrawing #menuRes
- return
- sub escapeSpecialCharacters
- set %specialChar_1 %
- set %specialChar_2 ^
- set %specialChar_3 &
- set %specialChar_4 <
- set %specialChar_5 >
- set %specialChar_6 |
- set %specialChar_7 '
- set %specialChar_8 `
- set %specialChar_9 ,
- set %specialChar_10 #smc
- set %specialChar_11 =
- set %specialChar_12 (
- set %specialChar_13 )
- set %specialChar_14 !
- set %specialChar_15 "
- for %si 1 15
- {
- set %char %specialChar_ . %si
- if %si = 1
- set %esc %
- else
- set %esc ^
- str count %1 %char
- set %scnt #strRes
- if %scnt > 0
- {
- for %ci %scnt 1
- {
- str pos %1 %char %ci
- str ins %1 %esc #strRes
- set %1 #strRes
- }
- }
- }
- return %1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement