Quick Color

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,207
This is just a really simple and useful system of mine.

Quick Color basically allows you to create shortcuts to the color codes. Rather than using "|c00FF0303" to color something red, you can now use it with a BBcode-ish style.

[red][/red] etc

Instead of me reinventing the wheel I decided to use the following lib in order to make my code simple and short. http://www.hiveworkshop.com/forums/jass-resources-412/snippet-string-233686/


  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set QC_code[1] = |c00FF0303
      • Set QC_code[2] = |c000042FF
      • Set QC_code[3] = |c001CE6B9
      • Set QC_code[4] = |c00540081
      • Set QC_code[5] = |c00FFFC01
      • Set QC_code[6] = |c00fEBA0E
      • Set QC_code[7] = |c0020C000
      • Set QC_code[8] = |c00E55BB0
      • Set QC_code[9] = |c00959697
      • Set QC_code[10] = |c007EBFF1
      • Set QC_start_command[1] = [red]
      • Set QC_start_command[2] = [darkblue]
      • Set QC_start_command[3] = [teal]
      • Set QC_start_command[4] = [purple]
      • Set QC_start_command[5] = [yellow]
      • Set QC_start_command[6] = [orange]
      • Set QC_start_command[7] = [green]
      • Set QC_start_command[8] = [pink]
      • Set QC_start_command[9] = [gray]
      • Set QC_start_command[10] = [lightblue]
      • Set QC_end_command[1] = [/red]
      • Set QC_end_command[2] = [/darkblue]
      • Set QC_end_command[3] = [/teal]
      • Set QC_end_command[4] = [/purple]
      • Set QC_end_command[5] = [/yellow]
      • Set QC_end_command[6] = [/orange]
      • Set QC_end_command[7] = [/green]
      • Set QC_end_command[8] = [/pink]
      • Set QC_end_command[9] = [/gray]
      • Set QC_end_command[10] = [/lightblue]
      • Set QC_total_commands = 10
JASS:
function ConvertString takes string text returns string
    local String s = String.create(text)
    local integer start
    local integer end
    local integer i = 1
	local integer i2 = 1
        loop
            exitwhen i > udg_QC_total_commands
			loop
				exitwhen i2 > 5
				set start = s.findBuffer(udg_QC_start_command[i], 0, s.size())
				
				if start >= 0 then
					call s.erase(start, StringLength(udg_QC_start_command[i]))
					call s.insert(start, udg_QC_code[i])
				endif
				
				set end = s.findBuffer(udg_QC_end_command[i], 0, s.size())
				if end < 0 then
					set i2 = 6
				endif
				
				if end >= 0 then
					call s.erase(end, StringLength(udg_QC_end_command[i]))
					call s.insert(end, "|r")
				endif
			endloop
			set i2 = 1
            set i = i + 1
        endloop
    return s.str
endfunction


  • demo
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Cinematic - Turn cinematic mode On for (All players)
      • Set msg = The [red]ball[/red] is blue [lightblue]and[/lightblue] taste like [green]chicken.[/green]
      • Custom script: set udg_msg = ConvertString(udg_msg)
      • Cinematic - Send transmission to (All players) from Paladin 0000 <gen> named Chaosy: Play No sound and display msg. Modify duration: Set to 99.00 seconds and Don't wait
25ulfh1.png



  • show all
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • For each (Integer loop) from 1 to QC_total_commands, do (Actions)
        • Loop - Actions
          • Set msg = (QC_start_command[loop] + (this is a test yo! + QC_end_command[loop]))
          • Custom script: call BJDebugMsg(ConvertString(udg_msg))
bjfpy1.png



  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set s = [red]Hello[/red] [green]mate[/green][red]![/red] [green]I am[/green] [red]really uncreative[/red]
      • Custom script: set udg_s = ConvertString(udg_s)
      • Game - Display to (All players) the text: s
>>
93b32c21edcffdcf295b93c60936d60c.png


Download - http://www.hiveworkshop.com/forums/pastebin.php?id=3v299e
 
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,207
A minor update on the project.

The system now supports the same color code more than once in a single string.
  • Untitled Trigger 001
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set s = [red]Hello[/red] [green]mate[/green][red]![/red] [green]I am[/green] [red]really uncreative[/red]
      • Custom script: set udg_s = ConvertString(udg_s)
      • Game - Display to (All players) the text: s
>>
93b32c21edcffdcf295b93c60936d60c.png


I will upload a demo map in a moment or two.
 
Status
Not open for further replies.
Top