Options
AS aDisplayOption
Options
AS aBackgroundOption
Primary
AS aPrimaryColour
Secondary
AS aSecondaryColour
Tertiary
AS aTertiaryColour
theLimit.Minimum = 0
theLimit.Maximum = 0 - 1
theSize.Titles = theLimit.Minimum
theSize.Canvases = theLimit.Minimum
theSize.Windows = theLimit.Minimum
theSize.Zones = theLimit.Minimum
theDisplay.Options.isScaled = 0
theDisplay.Options.isSmoothed = -1
' Declare RGB Colors (Primary, Secondary, and Tertiary)
' Initialize Grayscales (8 Brightnesses)
thePalette.Grayscale.Black
= _RGBA32(0, 0, 0, 255)thePalette.Grayscale.Darkest
= _RGBA32(31, 31, 31, 255)thePalette.Grayscale.Darker
= _RGBA32(63, 63, 63, 255)thePalette.Grayscale.Dark
= _RGBA32(95, 95, 95, 255)thePalette.Grayscale.Neutral
= _RGBA32(127, 127, 127, 255)thePalette.Grayscale.Light
= _RGBA32(159, 159, 159, 255)thePalette.Grayscale.Lighter
= _RGBA32(191, 191, 191, 255)thePalette.Grayscale.Lightest
= _RGBA32(223, 223, 223, 255)thePalette.Grayscale.White
= _RGBA32(255, 255, 255, 255)
' Initialize Colors (Primary, Secondary, and Tertiary)
thePalette.Primary.Red
= _RGBA32(255, 0, 0, 255)thePalette.Primary.Green
= _RGBA32(0, 255, 0, 255)thePalette.Primary.Blue
= _RGBA32(0, 0, 255, 255)thePalette.Secondary.Cyan = thePalette.Primary.Green + thePalette.Primary.Blue
thePalette.Secondary.Magenta = thePalette.Primary.Red + thePalette.Primary.Blue
thePalette.Secondary.Yellow = thePalette.Primary.Red + thePalette.Primary.Green
thePalette.Tertiary.Azure = thePalette.Primary.Blue + thePalette.Secondary.Cyan
thePalette.Tertiary.Violet = thePalette.Primary.Blue + thePalette.Secondary.Magenta
thePalette.Tertiary.Rose = thePalette.Primary.Red + thePalette.Secondary.Magenta
thePalette.Tertiary.springGreen = thePalette.Primary.Green + thePalette.Secondary.Cyan
thePalette.Tertiary.Orange = thePalette.Primary.Red + thePalette.Secondary.Yellow
thePalette.Tertiary.Chartreuse = thePalette.Primary.Green + thePalette.Secondary.Yellow
' Declare Theme colors
' Initialize Theme colors
theTheme.activeTitlebar = thePalette.Tertiary.Azure + thePalette.Secondary.Magenta
theTheme.inactiveTitlebar = thePalette.Tertiary.Azure + thePalette.Tertiary.springGreen
theTheme.resizeBox = thePalette.Grayscale.Light
' Declare global arrays
' Declare mouse cursor variable
DISPLAY_aspectRatio 1.33, 1
BACKGROUND_init thePalette.Primary.Red, thePalette.Tertiary.Orange, "CBOX"
BACKGROUND_image "ggravity.jpg", "CENTER"
BACKGROUND_put
attempts = attempts + 1
Status "Listening on port 65535..."
maxConnections = 65535 - 1024
MOUSE_probe
'detect which client is being hovered
IF theMouse.positionX
<> oldMx
OR theMouse.positionY
<> oldMy
THEN hover = 0
oldMx = theMouse.positionX
oldMy = theMouse.positionY
IF theMouse.positionX
>= client
(i
).x
AND theMouse.positionX
<= client
(i
).x
+ client
(i
).w
AND theMouse.positionY
>= client
(i
).y
AND theMouse.positionY
<= client
(i
).y
+ client
(i
).h
THEN hover = i
mouseDown = true
SWAP client
(hover
), client
(totalClients
) hover = totalClients
dragging = hover: dragX = theMouse.positionX: dragY = theMouse.positionY
originalX = theMouse.positionX: originalY = theMouse.positionY
Status
"Dragging client #" + STR$(dragging
) client(dragging).x = client(dragging).x + (theMouse.positionX - dragX)
client(dragging).y = client(dragging).y + (theMouse.positionY - dragY)
dragX = theMouse.positionX
dragY = theMouse.positionY
IF theMouse.positionX
= originalX
AND themousepositiony
= originalY
THEN 'just a click
b$
= "CLICK>" + MKI$(theMouse.positionX
- client
(dragging
).x
) + MKI$(theMouse.positionY
- client
(dragging
).y
) Send client(dragging).handle, b$
dragging = false
Status "Idle."
mouseDown = false
mouse2down = false
'close this client
closeClient hover
'look for new clients until limit is reached
Status "new client connected; handshaking..."
totalClients = totalClients + 1
client(totalClients).handle = newClient
Send newClient, "MSG>HELLO!"
reply = false
GET newClient
, , incomingData$
stream(totalClients) = stream(totalClients) + incomingData$
thisData$
= LEFT$(stream
(totalClients
), INSTR(stream
(totalClients
), "<END>") - 1) stream
(totalClients
) = MID$(stream
(totalClients
), INSTR(stream
(totalClients
), "<END>") + 5) thisCommand$
= LEFT$(thisData$
, INSTR(thisData$
, ">") - 1) thisCommand$ = thisData$
thisData$
= MID$(thisData$
, LEN(thisCommand$
) + 2)
IF thisCommand$
= "HELLO" THEN client
(totalClients
).w
= CVI(LEFT$(thisData$
, 2)) client
(totalClients
).h
= CVI(RIGHT$(thisData$
, 2)) client(totalClients).active = true
client
(totalClients
).ping
= TIMER totalIDs = totalIDs + 1
client(totalClients).id = totalIDs
failed:
Status "Connection failed!"
totalClients = totalClients - 1
BACKGROUND_put
PRINT "total clients:"; totalClients
Status ""
FOR i
= 1 TO totalClients
b$ = "PING>"
Send client(i).handle, b$
GET client
(i
).handle
, , incomingData$
stream(i) = stream(i) + incomingData$
thisData$
= LEFT$(stream
(i
), INSTR(stream
(i
), "<END>") - 1) stream
(i
) = MID$(stream
(i
), INSTR(stream
(i
), "<END>") + 5) thisCommand$
= LEFT$(thisData$
, INSTR(thisData$
, ">") - 1) thisCommand$ = thisData$
thisData$
= MID$(thisData$
, LEN(thisCommand$
) + 2)
client
(i
).image
= _NEWIMAGE(client
(i
).w
, client
(i
).h
, 32) _MEMPUT imgMem
, imgMem.OFFSET
, thisData$
client(i).active = false
totalClients = totalClients - 1
'show ping:
box client(i).x, client(i).y, client(i).w - 1, client(i).h - 1, 1
Titlebar client(i).x + 2, client(i).y + 2, client(i).w - 5, 23, thePalette.Grayscale.Black
box2 client(i).x + (client(i).w - 48), client(i).y + 3, 20, 20, 1, 7
box2 client(i).x + (client(i).w - 25), client(i).y + 3, 20, 20, 1, 2
box3 client(i).x + 4, client(i).y + 3, 20, 20, 1, 1, 7
LINE (client
(i
).x
, client
(i
).y
)-(client
(i
).x
+ client
(i
).w
- 1, client
(i
).y
+ client
(i
).h
- 1), mycolor~&
, BF
'window title
'window contents
_PUTIMAGE (client
(i
).x
+ 2, client
(i
).y
+ 26)-(client
(i
).x
+ client
(i
).w
- 2, client
(i
).y
+ client
(i
).h
- 2), client
(i
).image
closeClient i
nextClient:
aspectRatio = inWidth / inHeight
theDisplay.sizeX = inSizeX
theDisplay.sizeY = inSizeY
theDisplay.Options.isFullscreen = inIsFullscreen
theDisplay.Handle
= _NEWIMAGE(theDisplay.sizeX
, theDisplay.sizeY
, 32) DISPLAY_fullscreen theDisplay.Options.isScaled, theDisplay.Options.isSmoothed
theDisplay.Options.isScaled = -1
theDisplay.Options.isSmoothed = -1
IF theDisplay.Options.isScaled
= -1 AND theDisplay.Options.isSmoothed
= -1 THEN theDisplay.Options.isScaled = -1
theDisplay.Options.isSmoothed = 0
IF theDisplay.Options.isScaled
= -1 AND theDisplay.Options.isSmoothed
= 0 THEN theDisplay.Options.isScaled = 0
theDisplay.Options.isSmoothed = -1
IF theDisplay.Options.isScaled
= 0 AND theDisplay.Options.isSmoothed
= -1 THEN theDisplay.Options.isScaled = 0
theDisplay.Options.isSmoothed = 0
IF theDisplay.Options.isScaled
= 0 AND theDisplay.Options.isSmoothed
= 0 THEN
BACKGROUND_add
BACKGROUND_horizontalLines inColor1, inColor2
BACKGROUND_verticalLines inColor1, inColor2
BACKGROUND_checkerBox inColor1, inColor2
BACKGROUND_colour inColor1: inColor2 = 0
_DEST theBackground.Handle
_PUTIMAGE (centeredX
, centeredY
)-(_WIDTH(Temporary
) + centeredX
, _HEIGHT(Temporary
) + centeredY
), Temporary
, theBackground.Handle
theBackground.Options.isCentered = -1
theBackground.Options.isScaled = -1
_PUTIMAGE (_WIDTH(Temporary
) * currentTileX
, _HEIGHT(Temporary
) * currentTileY
), Temporary
, theBackground.Handle
theBackground.Options.isTiled = -1
_DEST theBackground.Handle
LINE (0, 0)-(_WIDTH(theBackground.Handle
), _HEIGHT(theBackground.Handle
)), inColour
, BF
_DEST theBackground.Handle
_DEST theBackground.Handle
_DEST theBackground.Handle
_PUTIMAGE , theBackground.Handle
, theDisplay.Handle
LINE (titlebarPositionX
, titlebarPositionY
)-(titlebarPositionX
+ titlebarWidth
, titlebarPositionY
+ titlebarHeight
), theTheme.activeTitlebar
, BF
LINE (boxPositionX
, boxPositionY
)-(boxPositionX
+ boxWidth
, boxPositionY
+ boxHeight
), thePalette.Grayscale.Lighter
, BF
LINE (boxPositionX
+ boxDepth
, boxPositionY
+ boxDepth
)-(boxPositionX
+ boxWidth
, boxPositionY
+ boxHeight
), thePalette.Grayscale.Darker
, BF
LINE (boxPositionX
+ boxDepth
, boxPositionY
+ boxDepth
)-((boxPositionX
+ boxWidth
) - boxDepth
, (boxPositionY
+ boxHeight
) - boxDepth
), thePalette.Grayscale.Neutral
, BF
interiorDepth = interiorDepth * boxDepth
LINE (boxPositionX
, boxPositionY
)-(boxPositionX
+ boxWidth
, boxPositionY
+ boxHeight
), thePalette.Grayscale.Darker
, BF
LINE (boxPositionX
+ boxDepth
, boxPositionY
+ boxDepth
)-(boxPositionX
+ boxWidth
, boxPositionY
+ boxHeight
), thePalette.Grayscale.Lighter
, BF
LINE (boxPositionX
+ boxDepth
, boxPositionY
+ boxDepth
)-((boxPositionX
+ boxWidth
) - boxDepth
, (boxPositionY
+ boxHeight
) - boxDepth
), thePalette.Grayscale.Neutral
, BF
LINE (boxPositionX
+ boxDepth
+ interiorDepth
, boxPositionY
+ boxDepth
+ interiorDepth
)-(boxPositionX
+ boxWidth
- boxDepth
- interiorDepth
, boxPositionY
+ boxHeight
- boxDepth
- interiorDepth
), thePalette.Grayscale.Lighter
, BF
LINE (boxPositionX
+ (boxDepth
* 2) + interiorDepth
, boxPositionY
+ (boxDepth
* 2) + interiorDepth
)-(boxPositionX
+ boxWidth
- boxDepth
- interiorDepth
, boxPositionY
+ boxHeight
- boxDepth
- interiorDepth
), thePalette.Grayscale.Darker
, BF
LINE (boxPositionX
+ (boxDepth
* 2) + interiorDepth
, boxPositionY
+ (boxDepth
* 2) + interiorDepth
)-(boxPositionX
+ boxWidth
- (boxDepth
* 2) - interiorDepth
, boxPositionY
+ boxHeight
- (boxDepth
* 2) - interiorDepth
), thePalette.Grayscale.Neutral
, BF
interiorDepthX = interiorDepthX * boxDepth
interiorDepthY = interiorDepthY * boxDepth
LINE (boxPositionX
, boxPositionY
)-(boxPositionX
+ boxWidth
, boxPositionY
+ boxHeight
), thePalette.Grayscale.Darker
, BF
LINE (boxPositionX
+ boxDepth
, boxPositionY
+ boxDepth
)-(boxPositionX
+ boxWidth
, boxPositionY
+ boxHeight
), thePalette.Grayscale.Lighter
, BF
LINE (boxPositionX
+ boxDepth
, boxPositionY
+ boxDepth
)-((boxPositionX
+ boxWidth
) - boxDepth
, (boxPositionY
+ boxHeight
) - boxDepth
), thePalette.Grayscale.Neutral
, BF
LINE (boxPositionX
+ boxDepth
+ interiorDepthX
, boxPositionY
+ boxDepth
+ interiorDepthY
)-(boxPositionX
+ boxWidth
- boxDepth
- interiorDepthX
, boxPositionY
+ boxHeight
- boxDepth
- interiorDepthY
), thePalette.Grayscale.Lighter
, BF
LINE (boxPositionX
+ (boxDepth
* 2) + interiorDepthX
, boxPositionY
+ (boxDepth
* 2) + interiorDepthY
)-(boxPositionX
+ boxWidth
- boxDepth
- interiorDepthX
, boxPositionY
+ boxHeight
- boxDepth
- interiorDepthY
), thePalette.Grayscale.Darker
, BF
LINE (boxPositionX
+ (boxDepth
* 2) + interiorDepthX
, boxPositionY
+ (boxDepth
* 2) + interiorDepthY
)-(boxPositionX
+ boxWidth
- (boxDepth
* 2) - interiorDepthX
, boxPositionY
+ boxHeight
- (boxDepth
* 2) - interiorDepthY
), thePalette.Grayscale.Neutral
, BF
b$ = "BYE!>"
Send client(ID).handle, b$
_DELAY .1 'give time for BYE! to be sent client(ID).active = false
FOR i
= ID
+ 1 TO totalClients
client(i - 1) = client(i)
totalClients = totalClients - 1
SUB Send
(channel
, __theData$
) theData$ = __theData$ + "<END>"