Login
Register
Menu
Home
Forum
JassDoc
Types
Functions
Variables
Help
Chat
Media
Search
Search posts
WC3 Modding Information Center
For your WC3 needs...
WC3 Modding Information Center
Forum
The Warcraft III Modding Community
Tavern
Code highlightning testing thread
Warcraft III:
Maps
Models
Skins
Icons
Spells / Systems
Tools
Tutorials
Snippets
JASS vJASS Spells and Systems
Tutorials
Chat @Discord
Code highlightning testing thread
Tavern
Started by
moyack
Views
8658
Replies
1
Users
1
2
Pages:
1
Go Down
0 Members and 1 Guest are viewing this topic.
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
Code highlightning testing thread
on:
December 28, 2011, 09:41:18 PM
Code: C++
Chapter03\colorandfont\main.
cpp
/*
* Copyright (c) 2006-2007, Johan Thelin
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of APress nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <QApplication>
#include <QFontDialog>
#include <QColorDialog>
class
Tester
:
public
QWidget
{
public
:
void
doColor
(
)
{
QColor color
=
QColorDialog
::
getColor
(
Qt
::
yellow
,
this
)
;
if
(
color.
isValid
(
)
)
{
qDebug
(
"ok"
)
;
}
}
void
doFont
(
)
{
bool
ok
;
QFont font
=
QFontDialog
::
getFont
(
&
ok,
QFont
(
"Arial"
,
18
)
,
this
,
tr
(
"Pick a font"
)
)
;
if
(
ok
)
{
qDebug
(
"ok"
)
;
}
}
}
;
int
main
(
int
argc,
char
**
argv
)
{
QApplication app
(
argc, argv
)
;
Tester t
;
t.
doColor
(
)
;
t.
doFont
(
)
;
return
0
;
}
WC3 Modding Information Center
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
Re: Code highlightning testing thread
Reply #1 on:
December 29, 2011, 05:27:48 PM
Code: jass
library
TimedLoop
//********************************************************
//* TimedLoop
//* ---------
//*
//* Requires jasshelper 0.9.G.1 or greater.
//*
//* A library + module that are meant to make those
//* array + timer loops easy, yet still faster than
//* other alternatives meant to be easy (In other words
//* no TriggerEvaluate is involved).
//*
//* The OOPness is interesting.
//*
//* Before implementing TimedLoop
//* your struct needs an onTimedLoop method that takes
//* nothing and returns boolean, if the method
//* returns false, the instance will get removed
//* from the loop and destroyed, else it will continue,
//* think of it as if the call asks the method a
//* question: "Should I continue the loop afterwards?"
//*
//* Alternatively, if you are not convinced, you may
//* use the TimedLoop_CONTINUE and TimedLoop_STOP
//* constants in the method's returns.
//*
//* After implementing TimedLoop, you can call
//* the startTimedLoop method to add the periodic event
//* to that instance, only call it once per instance.
//*
//* I recommend to call implement just bellow the
//* declaration of the onLoop method, else it will
//* actually use TriggerEvaluate, which is lame. Remind
//* me to implement a topsort in jasshelper.
//*
//* If you feel the need to destroy the struct outside
//* the loop, well, you'll have to add a flag to it so
//* you send a message to onLoop to make it return false.
//* A more complicated module to allow that easily would
//* come later.
//*
//********************************************************
//========================================================
// config:
globals
public
constant
real
PERIOD = 0.025
// A lower value and everything using the module will
// look better, yet performance will drop.
endglobals
//========================================================
// implementation:
//
globals
public
constant
boolean
STOP =
false
public
constant
boolean
CONTINUE =
true
endglobals
//===========================
module
TimedLoop
// god bless private module members.
//
private
static
thistype
array
V
// The array
private
static
integer
N = 0
// The count
private
static
timer
T =
null
// the timer, one per
// struct that implements this
private
static
method
onExpire
takes
nothing
returns
nothing
local
integer
n = 0
local
thistype
this
// yay for odd-sounding syntax constructs
local
integer
i = 0
loop
exitwhen
(i==
thistype
.N)
set
this
= .V[i]
if
(
this
.onTimedLoop() == CONTINUE )
then
set
.V[n] =
this
set
n=n+1
else
call
this
.destroy()
endif
set
i=i+1
endloop
set
thistype
.N = n
if
(n== 0)
then
call
PauseTimer
(.T)
endif
endmethod
public
method
startTimedLoop
takes
nothing
returns
nothing
set
.V[.N] =
this
set
.N=.N + 1
if
(.N == 1)
then
if
(.T ==
null
)
then
set
.T =
CreateTimer
()
endif
call
TimerStart
(.T, PERIOD,
true
,
function
thistype
.onExpire)
endif
endmethod
endmodule
endlibrary
«
Last Edit: December 29, 2011, 05:38:38 PM by moyack
»
WC3 Modding Information Center
Print
Pages:
1
Go Up
« previous
next »
WC3 Modding Information Center
Forum
The Warcraft III Modding Community
Tavern
Code highlightning testing thread
Suggested Topics
BBcode testing
Started by
moyack
Replies: 1
Views: 9416
Tavern
[Snippet] FireCode
Started by
Magtheridon96
Replies: 7
Views: 14474
Rejected Codes & Snippets
Prefix for threads ready.... just wondering what to put
Started by
moyack
Replies: 1
Views: 6789
Site Discussion
[HELP] Improving Effect over time code
Started by
moyack
Replies: 2
Views: 7835
General Jass Discussion
PortaMx-SEF 1.54
|
PortaMx © 2008-2015
,
PortaMx corp.
Search
Username
Password
Always stay logged in
Forgot your password?