Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.97 KB | None | 0 0
  1. ; Journal Viewer
  2. ;
  3. ;
  4. ; DejaVu fonts:
  5. ; https://sourceforge.net/projects/dejavu/
  6. ;
  7. ; 1. Download und extract the archive.
  8. ; 2. Open the "ttf" folder.
  9. ; 3. Install "DejaVuSansMono.ttf" and "DejaVuSansMono-Bold.ttf".
  10. ; (Right-click the files and select "Install".)
  11. ;
  12.  
  13.  
  14. ;========================================
  15. ;USER SETTINGS
  16.  
  17. set #lpc 100
  18.  
  19. ;window
  20. set %windowWidth 750
  21. set %windowHeight 800
  22. set %windowTitle Journal , #spc , Viewer
  23. set %fontName DejaVu , #spc , Sans , #spc , Mono
  24.  
  25.  
  26. ;list
  27. set %listBackgroundColor $222827
  28. set %listFontColor $2EE2A6
  29. set %listFontName DejaVu , #spc , Sans , #spc , Mono
  30. set %listFontSize 12
  31. set %listFontStyle b
  32.  
  33. set %maxLineLength 70
  34. set %indentLength 16
  35.  
  36. sub formatMessage
  37. ; %1: index, %2: time, %3: channel, %4: name, %5: text, %6: jindex
  38. return %2 , #spc , [ , %3 , ] , #spc , < , %4 , > , #spc , %5 , #spc ; , ( , %6 , )
  39.  
  40.  
  41.  
  42.  
  43. ;========================================
  44. ;MISC SETTINGS
  45.  
  46. ;list
  47. set %listX 2
  48. set %listY 24
  49. set %listWidth %windowWidth - %listX - 2
  50. set %listHeight %windowHeight - %listY - 2
  51.  
  52. ;channel checkboxes
  53. set %checkboxWidth 80
  54. set %checkboxSpacing 10
  55.  
  56. ;channels
  57.  
  58. set %channel_1 g
  59. set %channel_2 a
  60. set %channel_3 c
  61. set %channel_4 t
  62. set %channel_count 4
  63.  
  64. set %channelTitle_1 Guild
  65. set %channelTitle_2 Alliance
  66. set %channelTitle_3 Public
  67. set %channelTitle_4 Trade
  68.  
  69. set %tag_new G
  70. set %tag_guild G
  71. set %tag_alliance A
  72. set %tag_public C
  73. set %tag_trade T
  74.  
  75.  
  76.  
  77.  
  78. ;========================================
  79. ;INIT
  80.  
  81. set #menubutton N/A
  82.  
  83. set %indentString #dot
  84. for %i 2 %indentLength
  85. {
  86. set %indentString %indentString , #spc
  87. }
  88.  
  89. if *journalViewer_activeChannels = N/A
  90. set *journalViewer_activeChannels gact
  91.  
  92. set %message_count 0
  93. set %line_count 0
  94. set %flagRedrawList #false
  95. set %flagDisableRedrawing #false
  96. set %flagSaveLog #false
  97. set %jStart #jindex + 1
  98.  
  99. gosub drawWindow
  100.  
  101. ;event sysmessage [public][TestString]: 123456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H123456789I123456789J
  102.  
  103. ;========================================
  104. ;MAIN loop
  105.  
  106. while #true
  107. {
  108. if #menubutton = closed
  109. halt
  110. gosub scanJournalLoop
  111. gosub updateActiveChannels
  112. gosub mgetDisableRedrawing
  113. if %flagRedrawList && ! %flagDisableRedrawing
  114. gosub redrawList
  115. }
  116.  
  117. halt
  118.  
  119.  
  120. ;========================================
  121. ;SUBS
  122.  
  123.  
  124.  
  125.  
  126.  
  127. sub scanJournalLoop
  128. if #jindex >= %jStart
  129. {
  130. set %jEnd #jIndex
  131. for %ji %jStart %jEnd
  132. {
  133. str ins #time : 3
  134. str ins #strRes : 6
  135. set %tmpTime #strRes
  136. scanjournal %ji
  137. set %journalEntry #journal
  138. str left %journalEntry 1
  139. set %firstChar #strres
  140. if %firstChar notin [<
  141. continue
  142. if %firstChar = <
  143. {
  144. set %nameOffset 0
  145. set %closingBracket >
  146. }
  147. else
  148. {
  149. set %nameOffset 1
  150. set %closingBracket ]
  151. }
  152. str pos %journalEntry %closingBracket
  153. set %posClosingBracket #strRes
  154. if %posClosingBracket < 3
  155. continue
  156. set %tmpTagLength %posClosingBracket - 2
  157. str mid %journalEntry 2 %tmpTagLength
  158. set %tmpTag #strRes
  159. set %tmpChannel %tag_ . %tmpTag
  160. if %tmpChannel = N/A
  161. continue
  162. str pos %journalEntry :
  163. set %posColon #strRes
  164. if %posColon < %posClosingBracket + 3 + %nameOffset
  165. continue
  166. set %nameStart %posClosingBracket + 2
  167. set %nameLength %posColon - %nameStart - %nameOffset
  168. str mid %journalEntry %nameStart %nameLength
  169. set %tmpName #strRes
  170. set %deleteCharacters %posColon + 1
  171. str del %journalEntry 1 %deleteCharacters
  172. set %tmpMessageText #strRes
  173. spcLoop:
  174. str pos %tmpMessageText _
  175. set %posUnderscore #strRes
  176. if %posUnderscore > 0
  177. {
  178. str del %tmpMessageText %posUnderscore 1
  179. str ins #strRes #spc %posUnderscore
  180. set %tmpMessageText #strRes
  181. goto spcLoop
  182. }
  183. set %message_count %message_count + 1
  184. set %messageChannel_ . %message_count %tmpChannel
  185. set %messageTime_ . %message_count %tmpTime
  186. set %messageName_ . %message_count %tmpName
  187. set %messageText_ . %message_count %tmpMessageText
  188. set %messageJindex_ . %message_count %ji
  189. gosub formatMessage %message_count %tmpTime %tmpChannel %tmpName %tmpMessageText %ji
  190. set %messageString_ . %message_count #result
  191. if %flagSaveLog = #true
  192. {
  193. gosub escapeSpecialCharacters #result
  194. execute cmd.exe /c "echo , #spc , #result , #spc , >> journal.log"
  195. }
  196. gosub addMessageToList %message_count
  197.  
  198. }
  199. set %jStart %jEnd + 1
  200. }
  201. return
  202.  
  203. sub addMessageToList ; %1 = message index
  204. set %tmpLineChannel %messageChannel_ . %1
  205. set %tmpMessageString %messageString_ . %1
  206. str len %tmpMessageString
  207. set %messageLength #strRes
  208.  
  209. set %row_i 0
  210. set %substrStart 1
  211.  
  212. while %substrStart <= %messageLength
  213. {
  214. set %row_i %row_i + 1
  215. if %row_i = 1
  216. {
  217. set %substrLength %maxLineLength
  218. set %tmpLineString
  219. }
  220. else
  221. {
  222. set %substrLength %maxLineLength - %indentLength
  223. set %tmpLineString %indentString
  224. }
  225. str mid %tmpMessageString %substrStart %substrLength
  226. set %substr #strRes
  227. if %substrStart + %substrLength <= %messageLength
  228. {
  229. str count %substr #spc
  230. if #strRes > 0
  231. {
  232. str pos %substr #spc #strRes
  233. set %substrLength #strRes
  234. str left %substr #strRes
  235. set %substr #strRes
  236. }
  237. }
  238. trimLoop:
  239. str left %substr 1
  240. if #strRes = #spc
  241. {
  242. str del %substr 1 1
  243. set %substr #strRes
  244. goto trimLoop
  245. }
  246. set %tmpLineString %tmpLineString , %substr
  247. set %tmpRow_ . %row_i %tmpLineString
  248. set %substrStart %substrStart + %substrLength
  249.  
  250. }
  251. set %tmpRow_count %row_i
  252.  
  253. for %row_i %tmpRow_count 1
  254. {
  255. set %tmpLineIndex %line_count + %tmpRow_count - %row_i + 1
  256. set %tmpLineString %tmpRow_ . %row_i
  257. set %lineChannel_ . %tmpLineIndex %tmpLineChannel
  258. set %lineString_ . %tmpLineIndex %tmpLineString
  259.  
  260. }
  261. set %line_count %line_count + %tmpRow_count
  262. if %tmpLineChannel in *journalViewer_activeChannels
  263. set %flagRedrawList #true
  264. return
  265.  
  266. sub drawWindow
  267. menu Font Name %fontName
  268. menu Clear
  269. menu Window Title %windowTitle
  270. menu Window Size %windowWidth %windowHeight
  271. menu Show
  272.  
  273. gosub drawCheckboxes
  274.  
  275. ;list settings
  276. menu Font Transparent #true
  277. menu Font Align Right
  278. menu Font Name %listFontName
  279. menu Font Size %listFontSize
  280. menu Font Style %listFontStyle
  281. menu Font Color %listFontColor
  282. menu Font BGColor %listBackgroundColor
  283.  
  284. ;dummy list
  285. menu List Create dummyList %listX %listY %listWidth %listHeight
  286.  
  287. return
  288.  
  289. sub drawCheckboxes
  290. ; 43, 60, 50, 45, 116
  291.  
  292. for %chi 1 %channel_count
  293. {
  294. set %tmpChk_i %channel_ . %chi
  295. set %tmpChkName chk_ , %tmpChk_i
  296. set %tmpChkTitle %channelTitle_ . %chi
  297. set %tmpChkX 2 + ( %chi - 1 ) * ( %checkboxWidth + %checkboxSpacing )
  298. set %tmpChkActive %tmpChk_i in *journalViewer_activeChannels
  299. menu check %tmpChkName %tmpChkX 2 %checkboxWidth 20 %tmpChkActive %tmpChkTitle
  300. }
  301.  
  302. set %tmpChkX %windowWidth - 130
  303. menu check chk_disableRedrawing %tmpChkX 2 120 20 #false disable redrawing
  304. return
  305.  
  306.  
  307. sub redrawList
  308. menu delete journal
  309. menu List Create journal %listX %listY %listWidth %listHeight
  310.  
  311. if %line_count > 0
  312. {
  313. for %lineIndex %line_count 1
  314. {
  315. if %lineChannel_ . %lineIndex in *journalViewer_activeChannels
  316. {
  317. menu list add journal %lineString_ . %lineIndex
  318. }
  319. }
  320. }
  321. set %flagRedrawList #false
  322. return
  323.  
  324.  
  325. sub updateActiveChannels
  326. set %tmpActiveChannels
  327. for %ci 1 %channel_count
  328. {
  329. set %chk_i %channel_ . %ci
  330. menu get chk_ , %chk_i
  331. if #menuRes = #true
  332. {
  333. set %tmpActiveChannels %tmpActiveChannels , %chk_i
  334. }
  335. }
  336. if *journalViewer_activeChannels <> %tmpActiveChannels
  337. {
  338. set *journalViewer_activeChannels %tmpActiveChannels
  339. set %flagRedrawList #true
  340. }
  341.  
  342. return
  343.  
  344.  
  345. sub mgetDisableRedrawing
  346. menu get chk_disableRedrawing
  347. if %flagDisableRedrawing && ! #menuRes
  348. set %flagRedrawList #true
  349. set %flagDisableRedrawing #menuRes
  350. return
  351.  
  352.  
  353. sub escapeSpecialCharacters
  354. set %specialChar_1 %
  355. set %specialChar_2 ^
  356. set %specialChar_3 &
  357. set %specialChar_4 <
  358. set %specialChar_5 >
  359. set %specialChar_6 |
  360. set %specialChar_7 '
  361. set %specialChar_8 `
  362. set %specialChar_9 ,
  363. set %specialChar_10 #smc
  364. set %specialChar_11 =
  365. set %specialChar_12 (
  366. set %specialChar_13 )
  367. set %specialChar_14 !
  368. set %specialChar_15 "
  369.  
  370. for %si 1 15
  371. {
  372. set %char %specialChar_ . %si
  373. if %si = 1
  374. set %esc %
  375. else
  376. set %esc ^
  377. str count %1 %char
  378. set %scnt #strRes
  379. if %scnt > 0
  380. {
  381. for %ci %scnt 1
  382. {
  383. str pos %1 %char %ci
  384. str ins %1 %esc #strRes
  385. set %1 #strRes
  386. }
  387. }
  388. }
  389. return %1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement