Split .gmk into separate files
2
src/Backgrounds/_resources.list.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources/>
|
2
src/Constants.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<constants/>
|
4
src/Extension Packages.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<extensionPackages>
|
||||
<package>Faucet Networking</package>
|
||||
</extensionPackages>
|
2
src/Fonts/_resources.list.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources/>
|
BIN
src/Game Information.txt
Normal file
16
src/Game Information.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<gameInformation>
|
||||
<windowPosition>
|
||||
<left>-1</left>
|
||||
<top>-1</top>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</windowPosition>
|
||||
<allowResize>true</allowResize>
|
||||
<backgroundColor>FFFFE1</backgroundColor>
|
||||
<formCaption>Game Information</formCaption>
|
||||
<mimicGameWindow>false</mimicGameWindow>
|
||||
<pauseGame>true</pauseGame>
|
||||
<showBorder>true</showBorder>
|
||||
<stayOnTop>false</stayOnTop>
|
||||
</gameInformation>
|
66
src/Global Game Settings.xml
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<settings>
|
||||
<graphics>
|
||||
<scalingPercent>-1</scalingPercent>
|
||||
<displayCursor>true</displayCursor>
|
||||
<useVsync>false</useVsync>
|
||||
<interpolateColors>false</interpolateColors>
|
||||
<colorOutsideRoom>000000</colorOutsideRoom>
|
||||
</graphics>
|
||||
<windowing>
|
||||
<startFullscreen>false</startFullscreen>
|
||||
<dontDrawBorder>false</dontDrawBorder>
|
||||
<allowWindowResize>false</allowWindowResize>
|
||||
<alwaysOnTop>false</alwaysOnTop>
|
||||
<dontShowButtons>false</dontShowButtons>
|
||||
<switchVideoMode>false</switchVideoMode>
|
||||
</windowing>
|
||||
<splashImage>
|
||||
<showCustom>false</showCustom>
|
||||
<partiallyTransparent>false</partiallyTransparent>
|
||||
<alphaTransparency>255</alphaTransparency>
|
||||
</splashImage>
|
||||
<progressBar>
|
||||
<mode>LOADBAR_DEFAULT</mode>
|
||||
<scaleImage>true</scaleImage>
|
||||
</progressBar>
|
||||
<keys>
|
||||
<letF1ShowGameInfo>true</letF1ShowGameInfo>
|
||||
<letF4SwitchFullscreen>false</letF4SwitchFullscreen>
|
||||
<letF5SaveF6Load>false</letF5SaveF6Load>
|
||||
<letF9Screenshot>false</letF9Screenshot>
|
||||
<letEscEndGame>false</letEscEndGame>
|
||||
<treatCloseAsEscape>false</treatCloseAsEscape>
|
||||
</keys>
|
||||
<errors>
|
||||
<displayErrors>true</displayErrors>
|
||||
<writeToLog>false</writeToLog>
|
||||
<abortOnError>false</abortOnError>
|
||||
<treatUninitializedAsZero>false</treatUninitializedAsZero>
|
||||
</errors>
|
||||
<gameInfo>
|
||||
<gameId>175401986</gameId>
|
||||
<author>Ikewise</author>
|
||||
<version>1.0</version>
|
||||
<information/>
|
||||
<versionMajor>1</versionMajor>
|
||||
<versionMinor>0</versionMinor>
|
||||
<versionRelease>0</versionRelease>
|
||||
<versionBuild>0</versionBuild>
|
||||
<company>Exoverse Games</company>
|
||||
<product>GimelBot</product>
|
||||
<copyright/>
|
||||
<description>GimelBot v1.0</description>
|
||||
<directPlayGuid>66d32cb0f1e18a45a8eb28ee48ffd6f6</directPlayGuid>
|
||||
</gameInfo>
|
||||
<system>
|
||||
<processPriority>PRIORITY_NORMAL</processPriority>
|
||||
<disableScreensavers>true</disableScreensavers>
|
||||
<freezeOnLoseFocus>false</freezeOnLoseFocus>
|
||||
</system>
|
||||
<includes>
|
||||
<overwriteExisting>false</overwriteExisting>
|
||||
<removeAtGameEnd>false</removeAtGameEnd>
|
||||
<useTempFolder>false</useTempFolder>
|
||||
</includes>
|
||||
</settings>
|
5
src/Objects/_resources.list.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="objNetControl" type="RESOURCE"/>
|
||||
<resource name="objTextbox" type="RESOURCE"/>
|
||||
</resources>
|
28
src/Objects/objNetControl.events/Close Button.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<event category="OTHER" id="30">
|
||||
<actions>
|
||||
<action id="603" library="1">
|
||||
<!--action name: Code-->
|
||||
<kind>CODE</kind>
|
||||
<allowRelative>false</allowRelative>
|
||||
<question>false</question>
|
||||
<canApplyTo>true</canApplyTo>
|
||||
<actionType>CODE</actionType>
|
||||
<functionName/>
|
||||
<relative>false</relative>
|
||||
<not>false</not>
|
||||
<appliesTo>.self</appliesTo>
|
||||
<arguments>
|
||||
<argument kind="STRING">if(serverSocket != noone) {
|
||||
irc_disconnect("Program ended by user");
|
||||
socket_destroy(serverSocket);
|
||||
}
|
||||
buffer_destroy(dataBuffer);
|
||||
font_delete(fntGameSystem);
|
||||
if background_exists(pseudoSurface){background_delete(pseudoSurface)}
|
||||
game_end();
|
||||
</argument>
|
||||
</arguments>
|
||||
</action>
|
||||
</actions>
|
||||
</event>
|
52
src/Objects/objNetControl.events/Create.xml
Normal file
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<event category="CREATE" id="0">
|
||||
<actions>
|
||||
<action id="603" library="1">
|
||||
<!--action name: Code-->
|
||||
<kind>CODE</kind>
|
||||
<allowRelative>false</allowRelative>
|
||||
<question>false</question>
|
||||
<canApplyTo>true</canApplyTo>
|
||||
<actionType>CODE</actionType>
|
||||
<functionName/>
|
||||
<relative>false</relative>
|
||||
<not>false</not>
|
||||
<appliesTo>.self</appliesTo>
|
||||
<arguments>
|
||||
<argument kind="STRING">textNick=textbox_create();
|
||||
textNick.single_line=true;
|
||||
textNick.text=botnick;
|
||||
textNick.color_selected=c_black;
|
||||
textNick.color_selection=$00FF00;
|
||||
|
||||
textServer=textbox_create();
|
||||
textServer.single_line=true;
|
||||
textServer.text=server;
|
||||
textServer.color_selected=c_black;
|
||||
textServer.color_selection=$00FF00;
|
||||
|
||||
textPort=textbox_create();
|
||||
textPort.single_line=true;
|
||||
textPort.text=string(port);
|
||||
textPort.max_chars=4;
|
||||
textPort.filter_chars="0123456789";
|
||||
textPort.color_selected=c_black;
|
||||
textPort.color_selection=$00FF00;
|
||||
|
||||
textChannel=textbox_create();
|
||||
textChannel.single_line=true;
|
||||
textChannel.text=channel;
|
||||
textChannel.color_selected=c_black;
|
||||
textChannel.color_selection=$00FF00;
|
||||
|
||||
textbox_focus=textNick;
|
||||
|
||||
// Scrollbar
|
||||
|
||||
chatScrollbar=scrollbar_create(1,sprScrollbar,1);
|
||||
checkScrollbar=1;
|
||||
</argument>
|
||||
</arguments>
|
||||
</action>
|
||||
</actions>
|
||||
</event>
|
71
src/Objects/objNetControl.events/Draw.xml
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<event category="DRAW" id="0">
|
||||
<actions>
|
||||
<action id="603" library="1">
|
||||
<!--action name: Code-->
|
||||
<kind>CODE</kind>
|
||||
<allowRelative>false</allowRelative>
|
||||
<question>false</question>
|
||||
<canApplyTo>true</canApplyTo>
|
||||
<actionType>CODE</actionType>
|
||||
<functionName/>
|
||||
<relative>false</relative>
|
||||
<not>false</not>
|
||||
<appliesTo>.self</appliesTo>
|
||||
<arguments>
|
||||
<argument kind="STRING">room_caption="GimelBot v"+botversion/*+" - Framerate: "+string(fps)+"/120"*/;
|
||||
|
||||
|
||||
// Draw the obtained data
|
||||
if(serverSocket != noone) {
|
||||
|
||||
if background_exists(pseudoSurface){draw_background(pseudoSurface,0,0);}
|
||||
scrollbar_draw_ext(chatScrollbar,room_width-16,0,room_height-32,1,string_count(EOL,chatLog));
|
||||
|
||||
} else {
|
||||
var dy;
|
||||
|
||||
draw_text(1,1,errorMessage);
|
||||
|
||||
// Bot Nick field
|
||||
dy=0;
|
||||
draw_text(251,168,"Bot Nickname:");
|
||||
draw_rectangle(422,164,550,180,1); // Text border
|
||||
textbox_draw(textNick,427,168,547,178);
|
||||
|
||||
// Server field
|
||||
dy+=1
|
||||
draw_text(251,168+dy*32,"Server:");
|
||||
draw_rectangle(422,164+dy*32,550,180+dy*32,1); // Text border
|
||||
textbox_draw(textServer,427,168+dy*32,547,178+dy*32);
|
||||
|
||||
// Port field
|
||||
dy+=1
|
||||
draw_text(251,168+dy*32,"Port:");
|
||||
draw_rectangle(422,164+dy*32,550,180+dy*32,1); // Text border
|
||||
textbox_draw(textPort,427,168+dy*32,547,178+dy*32);
|
||||
|
||||
// Channel field
|
||||
dy+=1
|
||||
draw_text(251,168+dy*32,"Channel:");
|
||||
draw_rectangle(422,164+dy*32,550,180+dy*32,1); // Text border
|
||||
textbox_draw(textChannel,427,168+dy*32,547,178+dy*32);
|
||||
|
||||
// Connect button
|
||||
draw_rectangle(357,307,444,337,1);
|
||||
if((mouse_x>356)&&(mouse_x<445)&&(mouse_y>306)&&(mouse_y<338)){
|
||||
draw_rectangle(357,307,444,337,0);
|
||||
draw_set_color(c_black);
|
||||
window_set_cursor(cr_handpoint);
|
||||
if(mouse_check_button_released(mb_left)){window_set_cursor(cr_default); irc_connect();}
|
||||
} else {
|
||||
window_set_cursor(cr_default);
|
||||
}
|
||||
draw_text(374,318,"Connect");
|
||||
if(draw_get_color()==c_black){draw_set_color($00FF00);}
|
||||
}
|
||||
</argument>
|
||||
</arguments>
|
||||
</action>
|
||||
</actions>
|
||||
</event>
|
51
src/Objects/objNetControl.events/Step.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<event category="STEP" id="0">
|
||||
<actions>
|
||||
<action id="603" library="1">
|
||||
<!--action name: Code-->
|
||||
<kind>CODE</kind>
|
||||
<allowRelative>false</allowRelative>
|
||||
<question>false</question>
|
||||
<canApplyTo>true</canApplyTo>
|
||||
<actionType>CODE</actionType>
|
||||
<functionName/>
|
||||
<relative>false</relative>
|
||||
<not>false</not>
|
||||
<appliesTo>.self</appliesTo>
|
||||
<arguments>
|
||||
<argument kind="STRING">if(serverSocket != noone) {
|
||||
if(tcp_eof(serverSocket)){
|
||||
if(socket_has_error(serverSocket)) {
|
||||
errorMessage="Connection error: " + socket_error(serverSocket);
|
||||
} else {
|
||||
errorMessage=currentMessage;
|
||||
}
|
||||
socket_destroy(serverSocket);
|
||||
serverSocket = noone;
|
||||
} else {
|
||||
tcp_receive_available(serverSocket);
|
||||
write_buffer(dataBuffer,serverSocket);
|
||||
|
||||
while(buffer_size(dataBuffer)) {
|
||||
data = read_delimited_string(dataBuffer,EOL);
|
||||
if(is_string(data)) {
|
||||
//<2F>A<EFBFBD>delimited<65>string<6E>was<61>found<6E>and<6E>returned,<2C>do<64>something<6E>with<74>it
|
||||
currentMessage=data;
|
||||
interpret_message();
|
||||
} else {
|
||||
//<2F>no<6E>delimiter<65>found<6E>(or<6F>invalid<69>buffer)
|
||||
buffer_clear(dataBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
if(get_scrollbarvalue(chatScrollbar)!=checkScrollbar){
|
||||
log_draw(1,0,1,50);
|
||||
checkScrollbar=get_scrollbarvalue(chatScrollbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
</argument>
|
||||
</arguments>
|
||||
</action>
|
||||
</actions>
|
||||
</event>
|
10
src/Objects/objNetControl.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<object id="0">
|
||||
<sprite/>
|
||||
<solid>false</solid>
|
||||
<visible>true</visible>
|
||||
<depth>0</depth>
|
||||
<persistent>false</persistent>
|
||||
<parent/>
|
||||
<mask/>
|
||||
</object>
|
10
src/Objects/objTextbox.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<object id="1">
|
||||
<sprite/>
|
||||
<solid>false</solid>
|
||||
<visible>false</visible>
|
||||
<depth>0</depth>
|
||||
<persistent>false</persistent>
|
||||
<parent/>
|
||||
<mask/>
|
||||
</object>
|
2
src/Paths/_resources.list.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources/>
|
4
src/Rooms/_resources.list.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="rmTest" type="RESOURCE"/>
|
||||
</resources>
|
101
src/Rooms/rmTest.xml
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<room>
|
||||
<caption/>
|
||||
<size height="500" width="800"/>
|
||||
<grid>
|
||||
<isometric>false</isometric>
|
||||
<snap x="16" y="16"/>
|
||||
</grid>
|
||||
<speed>120</speed>
|
||||
<persistent>false</persistent>
|
||||
<creationCode>game_init();
|
||||
</creationCode>
|
||||
<backgroundColor>000000</backgroundColor>
|
||||
<drawBackgroundColor>true</drawBackgroundColor>
|
||||
<backgrounds>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
<backgroundDef>
|
||||
<visibleOnRoomStart>false</visibleOnRoomStart>
|
||||
<isForeground>false</isForeground>
|
||||
<backgroundImage/>
|
||||
<offset x="0" y="0"/>
|
||||
<speed x="0" y="0"/>
|
||||
<tileHorizontally>true</tileHorizontally>
|
||||
<tileVertically>true</tileVertically>
|
||||
<stretch>false</stretch>
|
||||
</backgroundDef>
|
||||
</backgrounds>
|
||||
<enableViews>false</enableViews>
|
||||
<instances/>
|
||||
<tiles/>
|
||||
<editorSettings remember="false"/>
|
||||
</room>
|
6
src/Scripts/General/_resources.list.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="game_init" type="RESOURCE"/>
|
||||
<resource name="num_prefix" type="RESOURCE"/>
|
||||
<resource name="string_parse_single" type="RESOURCE"/>
|
||||
</resources>
|
32
src/Scripts/General/game_init.gml
Normal file
@ -0,0 +1,32 @@
|
||||
globalvar server, port, channel, botnick, botversion;
|
||||
|
||||
server="192.168.0.40";
|
||||
port=6667;
|
||||
channel="#lobby";
|
||||
botnick="GimelBot";
|
||||
|
||||
botversion="1.0";
|
||||
|
||||
globalvar serverSocket, dataBuffer, errorMessage, currentMessage, printMessage, pseudoSurface, EOL;
|
||||
|
||||
serverSocket=noone;
|
||||
dataBuffer=buffer_create();
|
||||
errorMessage="";
|
||||
EOL=chr(13)+chr(10);
|
||||
|
||||
globalvar chatLog, chatWidth;
|
||||
chatLog="";
|
||||
chatWidth=room_width-16
|
||||
|
||||
globalvar fntGameSystem, fntRomulus, fntCyberspace;
|
||||
|
||||
fntGameSystem = font_add_sprite(sprGameSystem,ord(' '),false,0);
|
||||
//fntRomulus = font_add_sprite(sprRomulus,ord('!'),true,2);
|
||||
//fntCyberspace = font_add_sprite(sprCyberspace,ord(' '),false,0);
|
||||
draw_set_font(fntGameSystem);
|
||||
draw_set_color($00FF00);
|
||||
draw_set_halign(fa_left);
|
||||
draw_set_valign(fa_top);
|
||||
|
||||
|
||||
instance_create(0,0,objNetControl);
|
21
src/Scripts/General/num_prefix.gml
Normal file
@ -0,0 +1,21 @@
|
||||
var strIN;
|
||||
var strST;
|
||||
|
||||
/*
|
||||
argument 0 = score (as a string)
|
||||
argument 1 = total width required
|
||||
*/
|
||||
|
||||
strIN = string(argument0);
|
||||
if argument1 > string_length(strIN)
|
||||
{
|
||||
strST = string_repeat("0", argument1 - string_length(strIN));
|
||||
}
|
||||
else
|
||||
{
|
||||
strST = "";
|
||||
}
|
||||
|
||||
strST += strIN;
|
||||
|
||||
return strST;
|
46
src/Scripts/General/string_parse_single.gml
Normal file
@ -0,0 +1,46 @@
|
||||
/// string_parse_single(str,token,n,ignore)
|
||||
//
|
||||
// Returns the nth substring from a string of elements separated by
|
||||
// a given token, or the separator token if an error occurred.
|
||||
//
|
||||
// eg. string_parse_single("cat|dog|house|bee", "|", 2, true) == "dog"
|
||||
//
|
||||
// str elements, string
|
||||
// token element separator, string
|
||||
// n element to return, real
|
||||
// ignore ignore empty substrings, bool
|
||||
//
|
||||
/// GMLscripts.com/license
|
||||
{
|
||||
var str, token, substr, ignore, N, tlen, temp, i;
|
||||
|
||||
str = argument0;
|
||||
token = argument1;
|
||||
N = argument2;
|
||||
ignore = argument3;
|
||||
|
||||
tlen = string_length( token);
|
||||
|
||||
substr = "";
|
||||
i = 0;
|
||||
while( string_length( str) != 0 && i < N) {
|
||||
temp = string_pos( token, str);
|
||||
if( temp) {
|
||||
if( temp != 1 || !ignore) {
|
||||
substr = string_copy(str, 1, temp - 1);
|
||||
i += 1;
|
||||
}
|
||||
str = string_copy( str, temp + tlen, string_length( str));
|
||||
}
|
||||
else {
|
||||
substr = str;
|
||||
i += 1;
|
||||
str = "";
|
||||
}
|
||||
}
|
||||
|
||||
if( i != N)
|
||||
return "";
|
||||
else
|
||||
return substr;
|
||||
}
|
13
src/Scripts/IRC Functions/_resources.list.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="irc_connect" type="RESOURCE"/>
|
||||
<resource name="interpret_message" type="RESOURCE"/>
|
||||
<resource name="bot_commands" type="RESOURCE"/>
|
||||
<resource name="timestamp" type="RESOURCE"/>
|
||||
<resource name="send_message" type="RESOURCE"/>
|
||||
<resource name="send_notice" type="RESOURCE"/>
|
||||
<resource name="send_ctcp" type="RESOURCE"/>
|
||||
<resource name="join_channel" type="RESOURCE"/>
|
||||
<resource name="part_channel" type="RESOURCE"/>
|
||||
<resource name="irc_disconnect" type="RESOURCE"/>
|
||||
</resources>
|
29
src/Scripts/IRC Functions/bot_commands.gml
Normal file
@ -0,0 +1,29 @@
|
||||
var sender, hostmask, msgtype, target, msgdata;
|
||||
sender=argument0;
|
||||
hostmask=argument1;
|
||||
msgtype=argument2;
|
||||
target=argument3;
|
||||
msgdata=argument4;
|
||||
|
||||
|
||||
// GimelBot main commands begin here
|
||||
if(msgtype=="PRIVMSG") {
|
||||
|
||||
if((msgdata=="!quit")&&(sender=="Ikewise")){irc_disconnect("Received shutdown command from "+sender);};
|
||||
if(msgdata=="!part"){part_channel(target);};
|
||||
|
||||
if(string_pos("!slap",msgdata)==1) {
|
||||
switch(string_pos(" ",msgdata)){
|
||||
case 0:
|
||||
send_ctcp("PRIVMSG",target,"ACTION slaps "+sender+" around a bit with a large trout");
|
||||
break;
|
||||
default:
|
||||
send_ctcp("PRIVMSG",target,"ACTION slaps "+string_copy(msgdata,string_pos(" ",msgdata)+1,string_length(msgdata))+" around a bit with a large trout");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(msgdata=="chk"){send_message(target,sender+": ack");};
|
||||
if(msgdata=="."){send_message(target,"omg a meteor");};
|
||||
|
||||
}
|
171
src/Scripts/IRC Functions/interpret_message.gml
Normal file
@ -0,0 +1,171 @@
|
||||
var sender, hostmask, msgtype, target, msgdata;
|
||||
|
||||
// Respond to server pings
|
||||
if(string_pos("PING",currentMessage)==1) {
|
||||
write_string(serverSocket,"PONG "+string_parse_single(currentMessage," ",2,true)+EOL);
|
||||
socket_send(serverSocket);
|
||||
}
|
||||
|
||||
|
||||
// Check if currentMessage is from a user or Service
|
||||
if(string_pos("!",string_parse_single(currentMessage," ",1,true))) {
|
||||
sender = string_copy(currentMessage,2,string_pos("!",currentMessage)-2);
|
||||
hostmask = string_copy(currentMessage,string_pos("!",currentMessage)+1,string_pos(" ",currentMessage)-string_pos("!",currentMessage)-1);
|
||||
msgtype = string_parse_single(currentMessage," ",2,true);
|
||||
target = string_parse_single(currentMessage," ",3,true);
|
||||
|
||||
if(string_count(" ",currentMessage)>2) {
|
||||
msgdata = string_copy(currentMessage,string_pos(target+" ",currentMessage)+string_length(target)+1,string_length(currentMessage));
|
||||
} else {
|
||||
msgdata="";
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
if(msgtype!="QUIT" && string_pos(":",target)==1){target=string_copy(target,2,string_length(target)-1)}
|
||||
if((msgtype=="PART"||msgtype=="TOPIC"||msgtype=="INVITE"||msgtype=="NOTICE"||msgtype=="PRIVMSG") && msgdata!=""){msgdata=string_copy(msgdata,2,string_length(msgdata)-1)}
|
||||
|
||||
} else {
|
||||
if(string_pos("NOTICE AUTH",currentMessage)==1) {
|
||||
printMessage = currentMessage;
|
||||
log_update(printMessage,chatWidth);
|
||||
} else {
|
||||
// Message not from user or Service, do not print
|
||||
printMessage = "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
// Format the message for display
|
||||
switch(msgtype) {
|
||||
case "QUIT":
|
||||
if(target==":"){printMessage="GLOBAL: "+timestamp()+"* Quits: "+sender+" ("+hostmask+")"};
|
||||
if(target!=":"){printMessage="GLOBAL: "+timestamp()+"* Quits: "+sender+" ("+hostmask+") ("+string_copy(target,2,string_length(target)-1)+" "+msgdata+")"};
|
||||
break;
|
||||
case "JOIN":
|
||||
if(sender==botnick){printMessage=target+": "+timestamp()+"* Now talking in "+target};
|
||||
if(sender!=botnick){printMessage=target+": "+timestamp()+"* Joins: "+sender+" ("+hostmask+")"};
|
||||
break;
|
||||
case "PART":
|
||||
if(msgdata==""){printMessage=target+": "+timestamp()+"* Parts: "+sender+" ("+hostmask+")"};
|
||||
if(msgdata!=""){printMessage=target+": "+timestamp()+"* Parts: "+sender+" ("+hostmask+") ("+msgdata+")"};
|
||||
break;
|
||||
case "KICK":
|
||||
if(string_parse_single(msgdata," ",1,true)!=botnick){
|
||||
printMessage=target+": "+timestamp()+"* "+string_parse_single(msgdata," ",1,true)+" was kicked by "+sender+" ("+string_parse_single(msgdata,":",2,true)+")";
|
||||
} else {
|
||||
printMessage=target+": "+timestamp()+"* You were kicked from "+target+" by "+sender+" ("+string_parse_single(msgdata,":",2,true)+")";
|
||||
join_channel(target);
|
||||
}
|
||||
break;
|
||||
case "MODE":
|
||||
printMessage=target+": "+timestamp()+"* "+sender+" sets mode: "+msgdata;
|
||||
break;
|
||||
case "TOPIC":
|
||||
printMessage=target+": "+timestamp()+"* "+sender+" changes topic to '"+msgdata+"'";
|
||||
break;
|
||||
case "INVITE":
|
||||
printMessage="GLOBAL: "+timestamp()+"* "+sender+" ("+hostmask+") invites you to join "+msgdata;
|
||||
join_channel(msgdata);
|
||||
break;
|
||||
case "NICK":
|
||||
printMessage="GLOBAL: "+timestamp()+"* "+sender+" is now known as "+target;
|
||||
break;
|
||||
case "NOTICE":
|
||||
if(string_pos("#",target)!=1){printMessage="DIRECT ("+sender+"): "+timestamp()+"* NOTICE: -"+sender+"- "+msgdata};
|
||||
if(string_pos("#",target)==1){printMessage=target+": "+timestamp()+"* NOTICE: -"+sender+"- "+msgdata};
|
||||
break;
|
||||
case "PRIVMSG":
|
||||
if(string_pos("#",target)==1){ // If a channel
|
||||
if(string_pos(chr(1),msgdata)==1){
|
||||
if(string_pos(" ",msgdata)){
|
||||
switch(string_parse_single(msgdata," ",1,true)){
|
||||
case chr(1)+"ACTION":
|
||||
printMessage=target+": "+timestamp()+"* "+sender+" "+string_copy(msgdata,string_pos(" ",msgdata)+1,string_length(msgdata));
|
||||
break;
|
||||
default:
|
||||
printMessage=target+": "+timestamp()+"* CTCP: "+string_copy(msgdata,2,string_pos(" ",msgdata)-2)+" "+string_parse_single(msgdata," ",2,true);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
printMessage=target+": "+timestamp()+"* CTCP: "+string_copy(msgdata,2,string_length(msgdata)-2);
|
||||
}
|
||||
} else {
|
||||
printMessage=target+": "+timestamp()+"<"+sender+"> "+msgdata;
|
||||
}
|
||||
} else { // If not a channel
|
||||
target = sender;
|
||||
if(string_pos(chr(1),msgdata)==1){
|
||||
if(string_pos(" ",msgdata)){
|
||||
switch(string_parse_single(msgdata," ",1,true)){
|
||||
case chr(1)+"ACTION":
|
||||
printMessage="DIRECT ("+sender+"): "+timestamp()+"* "+sender+" "+string_copy(msgdata,string_pos(" ",msgdata)+1,string_length(msgdata));
|
||||
break;
|
||||
default:
|
||||
printMessage="DIRECT ("+sender+"): "+timestamp()+"* CTCP: "+string_copy(msgdata,2,string_pos(" ",msgdata)-2)+" "+string_parse_single(msgdata," ",2,true);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
printMessage="DIRECT ("+sender+"): "+timestamp()+"* CTCP: "+string_copy(msgdata,2,string_length(msgdata)-2);
|
||||
}
|
||||
} else {
|
||||
printMessage="DIRECT ("+sender+"): "+timestamp()+"<"+sender+"> "+msgdata;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
// Add the incoming message to the display
|
||||
if(printMessage!="") {
|
||||
log_update(printMessage,chatWidth);
|
||||
}
|
||||
|
||||
|
||||
// CTCP Responses
|
||||
if(msgtype=="PRIVMSG"){
|
||||
if(string_pos(chr(1),msgdata)==1){
|
||||
if(string_pos(" ",msgdata)){
|
||||
if(string_parse_single(msgdata," ",1,true)==chr(1)+"PING"){send_ctcp("NOTICE",sender,"PING "+string_copy(msgdata,string_pos(" ",msgdata)+1,string_length(msgdata)-(string_pos(" ",msgdata)+1)));};
|
||||
} else {
|
||||
if(string_copy(msgdata,1,5)==chr(1)+"TIME"){
|
||||
var date, weekday, month;
|
||||
date = date_current_datetime();
|
||||
switch(date_get_weekday(date)){
|
||||
case 1: weekday="Sun"; break;
|
||||
case 2: weekday="Mon"; break;
|
||||
case 3: weekday="Tue"; break;
|
||||
case 4: weekday="Wed"; break;
|
||||
case 5: weekday="Thur"; break;
|
||||
case 6: weekday="Fri"; break;
|
||||
case 7: weekday="Sat"; break;
|
||||
}
|
||||
switch(date_get_month(date)){
|
||||
case 1: month="Jan"; break;
|
||||
case 2: month="Feb"; break;
|
||||
case 3: month="Mar"; break;
|
||||
case 4: month="Apr"; break;
|
||||
case 5: month="May"; break;
|
||||
case 6: month="Jun"; break;
|
||||
case 7: month="July"; break;
|
||||
case 8: month="Aug"; break;
|
||||
case 9: month="Sep"; break;
|
||||
case 10: month="Oct"; break;
|
||||
case 11: month="Nov"; break;
|
||||
case 12: month="Dec"; break;
|
||||
}
|
||||
send_ctcp("NOTICE",sender,"TIME "+weekday+" "+month+" "+string(date_get_day(date))+" "+string(date_get_hour(date))+":"+string(date_get_minute(date))+":"+string(date_get_second(date))+" "+string(date_get_year(date)));
|
||||
}
|
||||
if(string_copy(msgdata,1,8)==chr(1)+"VERSION"){send_ctcp("NOTICE",sender,"VERSION GimelBot v"+botversion+" by Ikewise");};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Run main bot functions
|
||||
bot_commands(sender, hostmask, msgtype, target, msgdata);
|
||||
|
||||
|
||||
|
15
src/Scripts/IRC Functions/irc_connect.gml
Normal file
@ -0,0 +1,15 @@
|
||||
botnick=textNick.text;
|
||||
server=textServer.text;
|
||||
port=real(textPort.text);
|
||||
channel=textChannel.text;
|
||||
|
||||
chatLog="Connecting to "+server+":"+string(port)+"..."+EOL;
|
||||
|
||||
serverSocket=tcp_connect(server, port);
|
||||
|
||||
write_string(serverSocket, "NICK "+ botnick + chr(10));
|
||||
write_string(serverSocket, "USER "+ botnick +" "+ botnick +" "+ botnick +" :GameMaker IRC bot" + EOL);
|
||||
|
||||
socket_send(serverSocket);
|
||||
|
||||
join_channel(channel);
|
5
src/Scripts/IRC Functions/irc_disconnect.gml
Normal file
@ -0,0 +1,5 @@
|
||||
write_string(serverSocket, "QUIT :" + argument0 + EOL);
|
||||
socket_send(serverSocket);
|
||||
|
||||
socket_destroy(serverSocket);
|
||||
serverSocket = noone;
|
2
src/Scripts/IRC Functions/join_channel.gml
Normal file
@ -0,0 +1,2 @@
|
||||
write_string(serverSocket, "JOIN :" + argument0 + EOL);
|
||||
socket_send(serverSocket);
|
2
src/Scripts/IRC Functions/part_channel.gml
Normal file
@ -0,0 +1,2 @@
|
||||
write_string(serverSocket, "PART " + argument0 + EOL);
|
||||
socket_send(serverSocket);
|
45
src/Scripts/IRC Functions/send_ctcp.gml
Normal file
@ -0,0 +1,45 @@
|
||||
// Sends a CTCP message to the IRC server.
|
||||
// send_message(type, target, message);
|
||||
|
||||
var type, target, message;
|
||||
|
||||
type = argument0;
|
||||
target = argument1;
|
||||
message = argument2;
|
||||
|
||||
write_string(serverSocket,type+" "+target+" :"+chr(1)+message+chr(1)+EOL);
|
||||
socket_send(serverSocket);
|
||||
|
||||
|
||||
if(string_pos("#",target)==1) {
|
||||
switch(type){
|
||||
case "PRIVMSG":
|
||||
if(string_pos("ACTION",message)==1) {
|
||||
log_update(target+": "+timestamp()+"* "+botnick+" "+string_copy(message,8,string_length(message)),chatWidth);
|
||||
} else {
|
||||
log_update(target+": "+timestamp()+"* CTCP SEND: "+message,chatWidth);
|
||||
}
|
||||
break;
|
||||
case "NOTICE":
|
||||
log_update(target+": "+timestamp()+"* CTCP RESPOND: "+message,chatWidth);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(type){
|
||||
case "PRIVMSG":
|
||||
if(string_pos("ACTION",message)==1) {
|
||||
log_update("DIRECT ("+target+"): "+timestamp()+"* "+botnick+" "+string_copy(message,7,string_length(message)),chatWidth);
|
||||
} else {
|
||||
log_update("DIRECT ("+target+"): "+timestamp()+"* CTCP SEND: "+message,chatWidth);
|
||||
}
|
||||
break;
|
||||
case "NOTICE":
|
||||
log_update("DIRECT ("+target+"): "+timestamp()+"* CTCP RESPOND: "+message,chatWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
17
src/Scripts/IRC Functions/send_message.gml
Normal file
@ -0,0 +1,17 @@
|
||||
// Sends a message to the IRC server.
|
||||
// send_message(target, message);
|
||||
|
||||
var target, message;
|
||||
|
||||
target = argument0;
|
||||
message = argument1;
|
||||
|
||||
write_string(serverSocket,"PRIVMSG "+target+" :"+message+EOL);
|
||||
socket_send(serverSocket);
|
||||
|
||||
|
||||
if(string_pos("#",target)==1) {
|
||||
log_update(target+": "+timestamp()+"<"+botnick+"> "+message,chatWidth);
|
||||
} else {
|
||||
log_update("DIRECT ("+target+"): "+timestamp()+"<"+botnick+"> "+message,chatWidth);
|
||||
}
|
17
src/Scripts/IRC Functions/send_notice.gml
Normal file
@ -0,0 +1,17 @@
|
||||
// Sends a notice to the IRC server.
|
||||
// send_notice(target, message);
|
||||
|
||||
var target, message;
|
||||
|
||||
target = argument0;
|
||||
message = argument1;
|
||||
|
||||
write_string(serverSocket,"NOTICE "+target+" :"+message+EOL);
|
||||
socket_send(serverSocket);
|
||||
|
||||
|
||||
if(string_pos("#",target)==1) {
|
||||
log_update(target+": "+timestamp()+"* NOTICE: -"+botnick+"- "+message,chatWidth);
|
||||
} else {
|
||||
log_update("DIRECT ("+target+"): "+timestamp()+"* NOTICE: -"+botnick+"- "+message,chatWidth);
|
||||
}
|
9
src/Scripts/IRC Functions/timestamp.gml
Normal file
@ -0,0 +1,9 @@
|
||||
var time, hour, minute, output;
|
||||
time = date_current_datetime();
|
||||
hour = date_get_hour(time);
|
||||
minute = date_get_minute(time);
|
||||
if(hour < 10) {hour = "0" + string(hour);}
|
||||
if(minute < 10) {minute = "0" + string(minute);}
|
||||
output = "[" + string(hour) + ":" + string(minute) + "] ";
|
||||
|
||||
return output;
|
7
src/Scripts/Scrollbars/_resources.list.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="scrollbar_create" type="RESOURCE"/>
|
||||
<resource name="scrollbar_draw" type="RESOURCE"/>
|
||||
<resource name="scrollbar_draw_ext" type="RESOURCE"/>
|
||||
<resource name="get_scrollbarvalue" type="RESOURCE"/>
|
||||
</resources>
|
12
src/Scripts/Scrollbars/get_scrollbarvalue.gml
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
|
||||
CALL: get_scrollbarvalue(id)
|
||||
|
||||
INFO: Returns with the value of the selected scrollbar.
|
||||
|
||||
ARGUMENTS: id = The ID of the scrollbar.
|
||||
|
||||
WRITTEN BY: Davve
|
||||
|
||||
*/
|
||||
return round(global.___sb[argument0,1])
|
34
src/Scripts/Scrollbars/scrollbar_create.gml
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
|
||||
CALL: scrollbar_create(type,sprite,mousewheel)
|
||||
|
||||
INFO: Creates a new scrollbar and returns with the ID of it.
|
||||
|
||||
ARGUMENTS: type = 0 if horizontal,
|
||||
1 if vertical.
|
||||
sprite = The sprite of the scrollbar.
|
||||
mousewheel = If you should be able to scroll with the mouse wheel.
|
||||
|
||||
WRITTEN BY: Davve
|
||||
|
||||
*/
|
||||
var type,spr,mw;
|
||||
type=argument0
|
||||
spr=argument1
|
||||
mw=argument2
|
||||
|
||||
if (!variable_global_exists("___sbcount")) {
|
||||
global.___sbcount=0
|
||||
global.___sbtimer=0
|
||||
global.___sbdrag=-1
|
||||
global.___mxprev=mouse_x
|
||||
global.___myprev=mouse_y
|
||||
global.___sbcurrent=-1
|
||||
}
|
||||
global.___sb[global.___sbcount,0]=type
|
||||
global.___sb[global.___sbcount,1]=0
|
||||
global.___sb[global.___sbcount,2]=spr
|
||||
global.___sb[global.___sbcount,3]=mw
|
||||
global.___sbcount+=1
|
||||
|
||||
return global.___sbcount-1
|
82
src/Scripts/Scrollbars/scrollbar_draw.gml
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
|
||||
CALL: scrollbar_draw(id,x,y,w/h,maxw/h)
|
||||
|
||||
INFO: Draws the selected scrollbar. The value is measured in pixels.
|
||||
|
||||
ARGUMENTS: id = The ID of the scrollbar to draw.
|
||||
x = The x starting position of the scrollbar.
|
||||
y = The y starting position of the scrollbar.
|
||||
w/h = The width or height of the scrollbar (buttons not included).
|
||||
maxw/h = The maximum width or height (buttons not included).
|
||||
|
||||
WRITTEN BY: Davve
|
||||
|
||||
*/
|
||||
var sb,xx,yy,wh,mwh,spr,sw,sh,sel,sel2,a,sp,ep,tp;
|
||||
sb=argument0
|
||||
xx=argument1
|
||||
yy=argument2
|
||||
wh=max(-16,argument3)
|
||||
mwh=argument4
|
||||
spr=global.___sb[sb,2]
|
||||
sw=sprite_get_width(spr)
|
||||
sh=sprite_get_height(spr)
|
||||
tp=global.___sb[sb,0]
|
||||
|
||||
if (global.___sbcurrent=sb) {
|
||||
global.___sbtimer=max(0,(global.___sbtimer-1)*mouse_check_button(mb_left))
|
||||
}
|
||||
for (a=((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) a<((xx+wh+sw)*(tp=0))+((yy+wh+sh)*(tp>0)) a+=2) {
|
||||
draw_sprite(spr,(15*(tp=0))+(19*(tp>0)),(a*(tp=0))+(xx*(tp>0)),(yy*(tp=0))+(a*(tp>0)))
|
||||
}
|
||||
if ((!mouse_check_button(mb_left) && global.___sbdrag>-1)) {
|
||||
global.___sbdrag=-1
|
||||
}
|
||||
if (mwh>wh && wh>0) {
|
||||
sp=((xx+sw)*(tp=0))+((yy+sh)*(tp>0))+(global.___sb[sb,1]*(wh/mwh))
|
||||
ep=sp+max((wh*(wh/mwh)),4)
|
||||
if (global.___sbdrag=sb && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<((xx+(sw*2)+wh)*(tp=0))+((yy+(sh*2)+wh)*(tp>0))) {
|
||||
global.___sb[sb,1]+=(mwh/wh)*(((mouse_x*(tp=0))+(mouse_y*(tp>0)))-((global.___mxprev*(tp=0))+(global.___myprev*(tp>0))))
|
||||
global.___mxprev=mouse_x
|
||||
global.___myprev=mouse_y
|
||||
}
|
||||
if (global.___sbcurrent=sb && global.___sb[sb,3]>0) {
|
||||
global.___sb[sb,1]+=((-1*mouse_wheel_up())+(1*mouse_wheel_down()))*ceil((mwh/wh)*((ep-sp)/3))
|
||||
}
|
||||
sel=(global.___sbdrag=-1 && (mouse_x*(tp=0))+(mouse_y*(tp>0))>=((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) && (mouse_x*(tp=0))+(mouse_y*(tp>0))<sp && mouse_check_button(mb_left) && (mouse_y*(tp=0))+(mouse_x*(tp>0))>(yy*(tp=0))+(xx*(tp>0)) && (mouse_y*(tp=0))+(mouse_x*(tp>0))<((yy+sh)*(tp=0))+((xx+sh)*(tp>0)))
|
||||
sel+=2*(global.___sbdrag=-1 && (mouse_x*(tp=0))+(mouse_y*(tp>0))>ep && (mouse_x*(tp=0))+(mouse_y*(tp>0))<((xx+sw+wh)*(tp=0))+((yy+sh+wh)*(tp>0)) && mouse_check_button(mb_left) && (mouse_y*(tp=0))+(mouse_x*(tp>0))>(yy*(tp=0))+(xx*(tp>0)) && (mouse_y*(tp=0))+(mouse_x*(tp>0))<((yy+sh)*(tp=0))+((xx+sh)*(tp>0)))
|
||||
if (sel>0 && global.___sbtimer=0) {
|
||||
global.___sb[sb,1]+=((-1*(sel=1))+(1*(sel=2)))*ceil((mwh/wh)*((ep-sp)))
|
||||
global.___sb[sb,1]=max(0,min(mwh-((ep-sp)*(mwh/wh)),global.___sb[sb,1]))
|
||||
global.___sbtimer=ceil(fps/(15-(12*mouse_check_button_pressed(mb_left))))
|
||||
global.___sbcurrent=sb
|
||||
}
|
||||
global.___sb[sb,1]=min(mwh-((ep-sp)*(mwh/wh)),max(0,global.___sb[sb,1]))
|
||||
sp=((xx+sw)*(tp=0))+((yy+sh)*(tp>0))+(global.___sb[sb,1]*(wh/mwh))
|
||||
ep=sp+max((wh*(wh/mwh)),4)
|
||||
for (a=floor(sp+1) a<=ceil(ep-2) a+=1) {
|
||||
draw_sprite(spr,(13*(tp=0))+(17*(tp>0)),(a*(tp=0))+(xx*(tp>0)),(yy*(tp=0))+(a*(tp>0)))
|
||||
}
|
||||
draw_sprite(spr,(12*(tp=0))+(16*(tp>0)),(floor(sp)*(tp=0))+(xx*(tp>0)),(floor(sp)*(tp>0))+(yy*(tp=0)))
|
||||
draw_sprite(spr,(14*(tp=0))+(18*(tp>0)),((ceil(ep)-2)*(tp=0))+(xx*(tp>0)),((ceil(ep)-2)*(tp>0))+(yy*(tp=0)))
|
||||
sel=(((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=sp && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<ep && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))>=(yy*(tp=0))+(xx*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))<((yy+sh)*(tp=0))+((xx+sw)*(tp>0)) && mouse_check_button_pressed(mb_left))
|
||||
if (sel=1 && global.___sbdrag=-1) {
|
||||
global.___sbcurrent=sb
|
||||
global.___sbdrag=sb
|
||||
global.___mxprev=mouse_x
|
||||
global.___myprev=mouse_y
|
||||
}
|
||||
} else if (global.___sbdrag=sb) {
|
||||
global.___sbdrag=-1
|
||||
}
|
||||
sel=(((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=(xx*(tp=0))+(yy*(tp>0)) && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))>=(yy*(tp=0))+(xx*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))<((yy+sh)*(tp=0))+((xx+sw)*(tp>0)) && mouse_check_button(mb_left) && global.___sbdrag=-1 && mwh>wh)
|
||||
sel2=(((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=((xx+wh+sw)*(tp=0))+((yy+wh+sh)*(tp>0)) && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<((xx+(sw*2)+wh)*(tp=0))+((yy+(sh*2)+wh)*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))>=(yy*(tp=0))+(xx*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))<((yy+sh)*(tp=0))+((xx+sw)*(tp>0)) && mouse_check_button(mb_left) && global.___sbdrag=-1 && mwh>wh)
|
||||
if (sel+sel2>0 && global.___sbtimer=0) {
|
||||
global.___sb[sb,1]+=((-1*(sel=1))+(1*(sel2=1)))*ceil((mwh/wh)*((ep-sp)/3))
|
||||
global.___sb[sb,1]=max(0,min(mwh-((ep-sp)*(mwh/wh)),global.___sb[sb,1]))
|
||||
global.___sbtimer=ceil(fps/(15-(12*mouse_check_button_pressed(mb_left))))
|
||||
global.___sbcurrent=sb
|
||||
}
|
||||
draw_sprite(spr,(0*(tp=0))+(6*(tp>0))+(sel>0 || mwh<=wh)+(mwh<=wh),xx,yy)
|
||||
draw_sprite(spr,(3*(tp=0))+(9*(tp>0))+(sel2>0 || mwh<=wh)+(mwh<=wh),((xx+wh+sw)*(tp=0))+(xx*(tp>0)),(yy*(tp=0))+((yy+wh+sh)*(tp>0)))
|
89
src/Scripts/Scrollbars/scrollbar_draw_ext.gml
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
|
||||
CALL: scrollbar_draw_ext(id,x,y,slotw/h,slots,maxslots)
|
||||
|
||||
INFO: Draws the selected scrollbar. The value is measured in slots.
|
||||
|
||||
ARGUMENTS: id = The ID of the scrollbar to draw.
|
||||
x = The x starting position of the scrollbar.
|
||||
y = The y starting position of the scrollbar.
|
||||
slotw/h = The width or height of a slot.
|
||||
slots = The number of slots to show.
|
||||
maxslots = The maximum number of slots.
|
||||
|
||||
WRITTEN BY: Davve
|
||||
|
||||
*/
|
||||
var sb,xx,yy,swh,s,ms,wh,mwh,spr,sw,sh,sel,sel2,a,sp,ep,tp;
|
||||
sb=argument0
|
||||
xx=argument1
|
||||
yy=argument2
|
||||
swh=argument3
|
||||
s=argument4
|
||||
ms=argument5
|
||||
wh=s*swh
|
||||
mwh=ms*swh
|
||||
spr=global.___sb[sb,2]
|
||||
sw=sprite_get_width(spr)
|
||||
sh=sprite_get_height(spr)
|
||||
tp=global.___sb[sb,0]
|
||||
|
||||
if (global.___sbcurrent=sb) {
|
||||
global.___sbtimer=max(0,(global.___sbtimer-1)*mouse_check_button(mb_left))
|
||||
}
|
||||
for (a=((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) a<((xx+wh+sw)*(tp=0))+((yy+wh+sh)*(tp>0)) a+=2) {
|
||||
draw_sprite(spr,(15*(tp=0))+(19*(tp>0)),(a*(tp=0))+(xx*(tp>0)),(yy*(tp=0))+(a*(tp>0)))
|
||||
}
|
||||
if (!mouse_check_button(mb_left) && global.___sbdrag>-1) {
|
||||
global.___sbdrag=-1
|
||||
}
|
||||
if (mwh>wh && wh>0) {
|
||||
sp=(((xx+sw)*(tp=0))+((yy+sh)*(tp>0)))+(global.___sb[sb,1]*((s/ms)*swh))
|
||||
ep=sp+max((wh*(wh/mwh)),4)
|
||||
if (global.___sbdrag=sb && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<((xx+(sw*2)+wh)*(tp=0))+((yy+(sh*2)+wh)*(tp>0))) {
|
||||
global.___sb[sb,1]+=((((mouse_x*(tp=0))+(mouse_y*(tp>0)))-((global.___mxprev*(tp=0))+(global.___myprev*(tp>0)))))/(wh/ms)
|
||||
global.___mxprev=mouse_x
|
||||
global.___myprev=mouse_y
|
||||
}
|
||||
if (global.___sbcurrent=sb && global.___sb[sb,3]>0) {
|
||||
global.___sb[sb,1]+=((-1*mouse_wheel_up())+(1*mouse_wheel_down()))
|
||||
}
|
||||
sel=(global.___sbdrag=-1 && (mouse_x*(tp=0))+(mouse_y*(tp>0))>=((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) && (mouse_x*(tp=0))+(mouse_y*(tp>0))<sp && mouse_check_button(mb_left) && (mouse_y*(tp=0))+(mouse_x*(tp>0))>(yy*(tp=0))+(xx*(tp>0)) && (mouse_y*(tp=0))+(mouse_x*(tp>0))<((yy+sh)*(tp=0))+((xx+sh)*(tp>0)))
|
||||
sel+=2*(global.___sbdrag=-1 && (mouse_x*(tp=0))+(mouse_y*(tp>0))>ep && (mouse_x*(tp=0))+(mouse_y*(tp>0))<((xx+sw+wh)*(tp=0))+((yy+sh+wh)*(tp>0)) && mouse_check_button(mb_left) && (mouse_y*(tp=0))+(mouse_x*(tp>0))>(yy*(tp=0))+(xx*(tp>0)) && (mouse_y*(tp=0))+(mouse_x*(tp>0))<((yy+sh)*(tp=0))+((xx+sh)*(tp>0)))
|
||||
if (sel>0 && global.___sbtimer=0) {
|
||||
global.___sb[sb,1]+=(-1*(sel=1))+(1*(sel=2))
|
||||
global.___sb[sb,1]=max(0,min(ms-s,global.___sb[sb,1]))
|
||||
global.___sbtimer=ceil(fps/(15-(12*mouse_check_button_pressed(mb_left))))
|
||||
global.___sbcurrent=sb
|
||||
}
|
||||
global.___sb[sb,1]=min(ms-s,max(0,global.___sb[sb,1]))
|
||||
if (global.___sbdrag<>sb) {
|
||||
global.___sb[sb,1]=round(global.___sb[sb,1])
|
||||
}
|
||||
sp=(((xx+sw)*(tp=0))+((yy+sh)*(tp>0)))+(global.___sb[sb,1]*((s/ms)*swh))
|
||||
ep=sp+max((wh*(wh/mwh)),4)
|
||||
for (a=floor(sp+1) a<=ceil(ep-2) a+=1) {
|
||||
draw_sprite(spr,(13*(tp=0))+(17*(tp>0)),(a*(tp=0))+(xx*(tp>0)),(yy*(tp=0))+(a*(tp>0)))
|
||||
}
|
||||
draw_sprite(spr,(12*(tp=0))+(16*(tp>0)),(floor(sp)*(tp=0))+(xx*(tp>0)),(floor(sp)*(tp>0))+(yy*(tp=0)))
|
||||
draw_sprite(spr,(14*(tp=0))+(18*(tp>0)),((ceil(ep)-2)*(tp=0))+(xx*(tp>0)),((ceil(ep)-2)*(tp>0))+(yy*(tp=0)))
|
||||
sel=(((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=sp && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<ep && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))>=(yy*(tp=0))+(xx*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))<((yy+sh)*(tp=0))+((xx+sw)*(tp>0)) && mouse_check_button_pressed(mb_left))
|
||||
if (sel=1 && global.___sbdrag=-1) {
|
||||
global.___sbcurrent=sb
|
||||
global.___sbdrag=sb
|
||||
global.___mxprev=mouse_x
|
||||
global.___myprev=mouse_y
|
||||
}
|
||||
} else if (global.___sbdrag=sb) {
|
||||
global.___sbdrag=-1
|
||||
}
|
||||
sel=(((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=(xx*(tp=0))+(yy*(tp>0)) && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<((xx+sw)*(tp=0))+((yy+sh)*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))>=(yy*(tp=0))+(xx*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))<((yy+sh)*(tp=0))+((xx+sw)*(tp>0)) && mouse_check_button(mb_left) && global.___sbdrag=-1 && mwh>wh)
|
||||
sel2=(((mouse_x*(tp=0))+(mouse_y*(tp>0)))>=((xx+wh+sw)*(tp=0))+((yy+wh+sh)*(tp>0)) && ((mouse_x*(tp=0))+(mouse_y*(tp>0)))<((xx+(sw*2)+wh)*(tp=0))+((yy+(sh*2)+wh)*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))>=(yy*(tp=0))+(xx*(tp>0)) && ((mouse_y*(tp=0))+(mouse_x*(tp>0)))<((yy+sh)*(tp=0))+((xx+sw)*(tp>0)) && mouse_check_button(mb_left) && global.___sbdrag=-1 && mwh>wh)
|
||||
if (sel+sel2>0 && global.___sbtimer=0) {
|
||||
global.___sb[sb,1]+=(-1*(sel=1))+(1*(sel2=1))
|
||||
global.___sb[sb,1]=max(0,min(ms-s,global.___sb[sb,1]))
|
||||
global.___sbtimer=ceil(fps/(15-(12*mouse_check_button_pressed(mb_left))))
|
||||
global.___sbcurrent=sb
|
||||
}
|
||||
draw_sprite(spr,(0*(tp=0))+(6*(tp>0))+(sel>0 || mwh<=wh)+(mwh<=wh),xx,yy)
|
||||
draw_sprite(spr,(3*(tp=0))+(9*(tp>0))+(sel2>0 || mwh<=wh)+(mwh<=wh),((xx+wh+sw)*(tp=0))+(xx*(tp>0)),(yy*(tp=0))+((yy+wh+sh)*(tp>0)))
|
7
src/Scripts/Textbox/_resources.list.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="textbox_create" type="RESOURCE"/>
|
||||
<resource name="textbox_draw" type="RESOURCE"/>
|
||||
<resource name="log_update" type="RESOURCE"/>
|
||||
<resource name="log_draw" type="RESOURCE"/>
|
||||
</resources>
|
22
src/Scripts/Textbox/log_draw.gml
Normal file
@ -0,0 +1,22 @@
|
||||
// log_draw(x, y, startline, numlines)
|
||||
//
|
||||
// log_x - X position on screen
|
||||
// log_y - Y position on screen
|
||||
// startline - First line to draw
|
||||
// numlines - Number of lines of the log to draw
|
||||
|
||||
var log_x, log_y, startline, numlines;
|
||||
|
||||
log_x=argument0;
|
||||
log_y=argument1;
|
||||
startline=argument2;
|
||||
numlines=argument3;
|
||||
|
||||
draw_set_color(c_black);
|
||||
draw_rectangle(0,0,room_width,room_height,0);
|
||||
draw_set_color($00FF00);
|
||||
|
||||
draw_text(log_x,log_y+(numlines*string_height("A"))-((get_scrollbarvalue(chatScrollbar)+1)*string_height("A")),chatLog);
|
||||
|
||||
if background_exists(pseudoSurface){background_delete(pseudoSurface)}
|
||||
pseudoSurface=background_create_from_screen(0,0,room_width,room_height,false,false);
|
52
src/Scripts/Textbox/log_update.gml
Normal file
@ -0,0 +1,52 @@
|
||||
// log_update(str,width)
|
||||
//
|
||||
// str - string to append to the log
|
||||
// width - width of area (in pixels) log will be displayed
|
||||
|
||||
var str, logw, i, loop;
|
||||
|
||||
str=argument0;
|
||||
logw=argument1;
|
||||
loop=true;
|
||||
|
||||
while (loop){
|
||||
if(string_width(str)>logw){
|
||||
// The string is too long to be displayed on one line.
|
||||
|
||||
if(string_pos(" ",str)&&(string_width(string_copy(str,1,string_pos(" ",str)))<logw)){
|
||||
// There's a space before str exceeds the display width
|
||||
i=string_length(str);
|
||||
repeat(string_length(str)){
|
||||
if((string_char_at(str,i)==" ")&&(string_width(string_copy(str,1,i))<logw)){
|
||||
chatLog=chatLog+string_replace_all(string_copy(str,1,i-1),"#","\#")+EOL;
|
||||
str=string_delete(str,1,i);
|
||||
break;
|
||||
}
|
||||
i-=1;
|
||||
}
|
||||
} else {
|
||||
// No space before str exceeds the display width
|
||||
i=string_length(str);
|
||||
repeat(string_length(str)){
|
||||
if(string_width(string_copy(str,1,i))<logw){
|
||||
str=string_insert("-",str,i-1);
|
||||
chatLog=chatLog+string_replace_all(string_copy(str,1,i-1),"#","\#")+EOL;
|
||||
str=string_delete(str,1,i);
|
||||
break;
|
||||
}
|
||||
i-=1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// The string will fit, just add it to the log.
|
||||
chatLog=chatLog+string_replace_all(str,"#","\#")+EOL;
|
||||
loop=false;
|
||||
}
|
||||
|
||||
// Update the Scrollbar
|
||||
if(get_scrollbarvalue(chatScrollbar)==string_count(EOL,chatLog)-2){
|
||||
global.___sb[chatScrollbar,1]+=1;
|
||||
}
|
||||
|
||||
}
|
49
src/Scripts/Textbox/textbox_create.gml
Normal file
@ -0,0 +1,49 @@
|
||||
/// textbox_create()
|
||||
|
||||
var i;
|
||||
i=instance_create(0,0,objTextbox)
|
||||
|
||||
// Feel free to change/use these variables after creating the object
|
||||
i.text="" // Text in the textbox
|
||||
i.single_line=0 // If true, the textbox is limited to one line
|
||||
i.read_only=0 // If true, the textbox contents cannot be changed in any way
|
||||
i.max_chars=0 // If larger than 0, sets the maximum allowed number of characters
|
||||
i.filter_chars="" // If not "", these are the only allowed characters, "0123456789" to only allow digits
|
||||
i.replace_char="" // If not "", replaces all characters with this (text variable remains unchanged)
|
||||
i.select_on_focus=0 // If true, all text will be selected upon focusing the textbox
|
||||
i.color_selected=-1 // The color of selected text, -1 for default
|
||||
i.color_selection=-1 // The color of the selection box, -1 for default
|
||||
|
||||
i.start=0 // Set the start line (multi-line) or start character (single-line)
|
||||
i.lines=1 // Access the amount of lines in the textbox (read only)
|
||||
i.line[0]="" // Access a specific line from the textbox (read only)
|
||||
|
||||
// Don't touch
|
||||
i.line_wrap[0]=0
|
||||
i.line_single[0]=0
|
||||
i.chars=0
|
||||
i.last_text=""
|
||||
i.last_width=0
|
||||
|
||||
if (instance_number(objTextbox)=1) {
|
||||
globalvar textbox_focus,textbox_lastfocus,textbox_select;
|
||||
globalvar textbox_key_delay,textbox_click,textbox_marker,textbox_mouseover;
|
||||
globalvar textbox_select_mouseline,textbox_select_mousepos,textbox_select_clickline,textbox_select_clickpos;
|
||||
globalvar textbox_select_startline,textbox_select_startpos,textbox_select_endline,textbox_select_endpos;
|
||||
textbox_focus=-1 // Holds the ID of the textbox being edited, you can change this during runtime
|
||||
textbox_select=-1 // Holds the ID of the textbox whose text is being selected
|
||||
textbox_lastfocus=-1
|
||||
textbox_click=0
|
||||
textbox_marker=0
|
||||
textbox_mouseover=-1
|
||||
textbox_select_startline=0
|
||||
textbox_select_startpos=0
|
||||
textbox_select_endline=0
|
||||
textbox_select_endpos=0
|
||||
textbox_select_mouseline=0
|
||||
textbox_select_mousepos=0
|
||||
textbox_select_clickline=0
|
||||
textbox_select_clickpos=0
|
||||
}
|
||||
|
||||
return i
|
685
src/Scripts/Textbox/textbox_draw.gml
Normal file
@ -0,0 +1,685 @@
|
||||
/// textbox_draw(id, x1, y1, x2, y2)
|
||||
|
||||
/// Draws a box with editable text at the given position and with the given dimensions.
|
||||
/// The properties of the textbox are stored in the given objTextbox instance id.
|
||||
/// See the textbox_create script for info about the properties.
|
||||
/// Use draw_set_font() and draw_set_color() to change the appearance of the text.
|
||||
|
||||
/// http://www.stuffbydavid.com
|
||||
|
||||
{
|
||||
var i,xx,yy,w,h;
|
||||
var color_normal,color_selected,color_selection,color_marker;
|
||||
var changetext,deletetext,inserttext,lineheight,mouseover;
|
||||
var realmousepos,realstartpos,realendpos;
|
||||
var a,b,c,l,p,ww,hh,str;
|
||||
|
||||
i=argument0
|
||||
xx=argument1
|
||||
yy=argument2
|
||||
w=argument3-argument1
|
||||
h=argument4-argument2
|
||||
|
||||
// Colors
|
||||
color_normal=draw_get_color()
|
||||
color_selected=c_white
|
||||
color_selection=make_color_rgb(51,153,255)
|
||||
color_marker=$00FF00
|
||||
if (i.color_selected>-1) color_selected=i.color_selected
|
||||
if (i.color_selection>-1) color_selection=i.color_selection
|
||||
|
||||
if (i.last_text!=i.text) {
|
||||
str=i.text
|
||||
str=string_replace_all(str,chr(13)+chr(10),chr(10))
|
||||
str=string_replace_all(str,chr(13),chr(10))
|
||||
if (i.max_chars>0) str=string_copy(str,1,i.max_chars)
|
||||
if (i.single_line) str=string_replace_all(str,chr(10)," ")
|
||||
i.text=str
|
||||
str+=chr(10)
|
||||
i.lines=0
|
||||
while (str!="") {
|
||||
i.line[i.lines]=string_copy(str,1,string_pos(chr(10),str)-1)
|
||||
i.line_wrap[i.lines]=0
|
||||
i.line_single[i.lines]=0
|
||||
i.lines+=1
|
||||
str=string_delete(str,1,string_pos(chr(10),str))
|
||||
}
|
||||
changetext=1
|
||||
} else changetext=0
|
||||
|
||||
deletetext=0
|
||||
inserttext=""
|
||||
lineheight=string_height(" ")
|
||||
mouseover=(mouse_x>=xx && mouse_x<xx+w && mouse_y>=yy && mouse_y<yy+h)
|
||||
|
||||
if (textbox_focus=i) {
|
||||
var keys,key_press,action;
|
||||
if (textbox_lastfocus!=i) { // Select all
|
||||
textbox_select_endline=i.lines-1 textbox_select_endpos=string_length(i.line[textbox_select_endline])
|
||||
if (i.select_on_focus) {textbox_select_startline=0 textbox_select_startpos=0}
|
||||
else {textbox_select_startline=textbox_select_endline textbox_select_startpos=textbox_select_endpos}
|
||||
textbox_select_mouseline=textbox_select_endline textbox_select_mousepos=textbox_select_endpos
|
||||
textbox_select_clickline=0 textbox_select_clickpos=0
|
||||
}
|
||||
//Automatic key presses
|
||||
keys[0]=vk_enter keys[1]=vk_backspace keys[2]=vk_delete keys[3]=ord("V") keys[4]=vk_right keys[5]=vk_left keys[6]=vk_up keys[7]=vk_down
|
||||
for (k=0 k<8 k+=1) {
|
||||
key_press[keys[k]]=0
|
||||
if (keyboard_check(keys[k])) {
|
||||
if (current_time-textbox_key_delay[k]>30) {
|
||||
key_press[keys[k]]=1
|
||||
textbox_key_delay[k]=current_time+500*keyboard_check_pressed(keys[k]) // 500 msec if first press, otherwise 30
|
||||
}
|
||||
} else textbox_key_delay[k]=0
|
||||
}
|
||||
|
||||
if (mouse_check_button_pressed(mb_left) && !keyboard_check(vk_shift)) textbox_focus=-1
|
||||
if (!i.read_only && textbox_select=-1) {
|
||||
deletetext=key_press[vk_backspace]-key_press[vk_delete] // 0=Do nothing, 1=Erase to left, -1=Erase to right, 2=Delete selected
|
||||
inserttext=keyboard_string
|
||||
}
|
||||
keyboard_string=""
|
||||
|
||||
//Controls
|
||||
if (!i.single_line) {
|
||||
i.start+=mouse_wheel_down()-mouse_wheel_up() // Mousewheel to scroll
|
||||
if (key_press[vk_enter] && !i.read_only) inserttext=chr(10) // Enter for linebreak
|
||||
}
|
||||
if (key_press[vk_right] || key_press[vk_left] || (key_press[vk_up] && textbox_select_mouseline>0) || (key_press[vk_down] && textbox_select_mouseline<i.lines-1)) { //Arrow keys to move marker
|
||||
if (key_press[vk_right] || key_press[vk_left]) {
|
||||
textbox_select_mousepos+=(key_press[vk_right]-key_press[vk_left]) // Move marker right or left
|
||||
if (textbox_select_mousepos>string_length(i.line[textbox_select_mouseline])) { // Check if beyond end of line
|
||||
if (textbox_select_mouseline<i.lines-1) { // Wrap around to next line
|
||||
textbox_select_mouseline+=1
|
||||
textbox_select_mousepos=0
|
||||
} else textbox_select_mousepos-=1
|
||||
}
|
||||
if (textbox_select_mousepos<0) { // Check if before start of line
|
||||
if (textbox_select_mouseline>0) {
|
||||
textbox_select_mouseline-=1
|
||||
textbox_select_mousepos=string_length(i.line[textbox_select_mouseline])
|
||||
} else textbox_select_mousepos+=1
|
||||
}
|
||||
}
|
||||
if (!i.single_line && (key_press[vk_up] || key_press[vk_down])) { // Move marker up/down
|
||||
var currentx,nextx;
|
||||
currentx=string_width(string_replace_all(string_copy(i.line[textbox_select_mouseline],1,textbox_select_mousepos),"#","\#"))
|
||||
nextx=0
|
||||
textbox_select_mouseline+=key_press[vk_down]-key_press[vk_up]
|
||||
for (textbox_select_mousepos=0 textbox_select_mousepos<=string_length(i.line[textbox_select_mouseline]) textbox_select_mousepos+=1) { // Find correct position
|
||||
nextx+=string_width(string_replace(string_char_at(i.line[textbox_select_mouseline],textbox_select_mousepos),"#","\#"))
|
||||
if (nextx>currentx) break
|
||||
}
|
||||
}
|
||||
if (!keyboard_check(vk_shift)) {
|
||||
textbox_select_clickline=textbox_select_mouseline
|
||||
textbox_select_clickpos=textbox_select_mousepos
|
||||
}
|
||||
textbox_select_startline=textbox_select_mouseline textbox_select_startpos=textbox_select_mousepos
|
||||
textbox_select_endline=textbox_select_mouseline textbox_select_endpos=textbox_select_mousepos
|
||||
textbox_marker=current_time
|
||||
}
|
||||
|
||||
action=-1
|
||||
if (mouse_check_button_pressed(mb_right) && mouseover && textbox_select=-1) { //Right-click menu
|
||||
if (i.read_only) {
|
||||
action=show_menu("Copy|-|Select all",-1)
|
||||
if (action=1) action=4
|
||||
if (action=0) action=1
|
||||
} else action=show_menu("Cut|Copy|Paste|Delete|-|Select all",-1)
|
||||
}
|
||||
if (keyboard_check(vk_control) && textbox_select=-1) { // Ctrl commands
|
||||
if (!i.read_only && keyboard_check_pressed(ord("X"))) action=0
|
||||
if (keyboard_check_pressed(ord("C"))) action=1
|
||||
if (!i.read_only && key_press[ord("V")]) action=2
|
||||
if (keyboard_check_pressed(ord("A"))) action=4
|
||||
}
|
||||
switch (action) {
|
||||
case 0: case 1: { // Cut/Copy text
|
||||
str=""
|
||||
if (textbox_select_startline=textbox_select_endline) { // Get text on single line
|
||||
str=string_copy(i.line[textbox_select_startline],textbox_select_startpos+1,textbox_select_endpos-textbox_select_startpos)
|
||||
} else {
|
||||
for (l=textbox_select_startline l<=textbox_select_endline l+=1) { // Get selected text
|
||||
if (l=textbox_select_startline) str+=string_delete(i.line[l],1,textbox_select_startpos)
|
||||
else if (l=textbox_select_endline) str+=string_copy(i.line[l],1,textbox_select_endpos)
|
||||
else str+=i.line[l]
|
||||
if (l<textbox_select_endline) {
|
||||
if (!i.line_wrap[l+1] && !i.line_single[l]) str+=chr(13)+chr(10)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (str!="") clipboard_set_text(str)
|
||||
if (action=0) deletetext=2
|
||||
break
|
||||
}
|
||||
case 2: { // Paste text
|
||||
inserttext=clipboard_get_text()
|
||||
inserttext=string_replace_all(inserttext,chr(13)+chr(10),chr(10))
|
||||
inserttext=string_replace_all(inserttext,chr(13),chr(10))
|
||||
break
|
||||
}
|
||||
case 3: { // Delete text
|
||||
deletetext=2
|
||||
break
|
||||
}
|
||||
case 4: { // Select all text
|
||||
textbox_select_startline=0 textbox_select_startpos=0
|
||||
textbox_select_endline=i.lines-1 textbox_select_endpos=string_length(i.line[textbox_select_endline])
|
||||
textbox_select_mouseline=textbox_select_endline textbox_select_mousepos=textbox_select_endpos
|
||||
textbox_select_clickline=0 textbox_select_clickpos=0
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Filter
|
||||
if (i.filter_chars!="" && inserttext!="") {
|
||||
str=""
|
||||
for (p=1 p<=string_length(inserttext) p+=1) {
|
||||
c=string_char_at(inserttext,p)
|
||||
str+=string_repeat(c,string_pos(c,i.filter_chars)>0)
|
||||
}
|
||||
inserttext=str
|
||||
}
|
||||
|
||||
// Delete
|
||||
if (deletetext!=0 || inserttext!="") {
|
||||
// Get real position in total string for mouse/start/end
|
||||
realmousepos=textbox_select_mousepos
|
||||
realstartpos=textbox_select_startpos
|
||||
realendpos=textbox_select_endpos
|
||||
for (l=0 l<textbox_select_mouseline l+=1) realmousepos+=string_length(i.line[l])+(!i.line_wrap[l+1] && !i.line_single[l])
|
||||
for (l=0 l<textbox_select_startline l+=1) realstartpos+=string_length(i.line[l])+(!i.line_wrap[l+1] && !i.line_single[l])
|
||||
for (l=0 l<textbox_select_endline l+=1) realendpos+=string_length(i.line[l])+(!i.line_wrap[l+1] && !i.line_single[l])
|
||||
|
||||
if (textbox_select_startline!=textbox_select_endline || textbox_select_startpos!=textbox_select_endpos) { //Several characters
|
||||
if (textbox_select_startline=textbox_select_endline) { // Same line, just do string_delete
|
||||
i.line[textbox_select_startline]=string_delete(i.line[textbox_select_startline],textbox_select_startpos+1,textbox_select_endpos-textbox_select_startpos)
|
||||
} else { // Delete all lines between the two points
|
||||
var linestodelete;
|
||||
linestodelete=textbox_select_endline-textbox_select_startline;
|
||||
i.line[textbox_select_startline]=string_copy(i.line[textbox_select_startline],1,textbox_select_startpos)+string_delete(i.line[textbox_select_endline],1,textbox_select_endpos)
|
||||
i.lines-=linestodelete
|
||||
for (l=textbox_select_startline+1 l<i.lines l+=1) {
|
||||
i.line[l]=i.line[l+linestodelete]
|
||||
i.line_wrap[l]=i.line_wrap[l+linestodelete]
|
||||
i.line_single[l]=i.line_single[l+linestodelete]
|
||||
}
|
||||
}
|
||||
i.text=string_delete(i.text,realstartpos+1,realendpos-realstartpos)
|
||||
} else if (deletetext<2) { // Single character
|
||||
if (deletetext=1) { // Delete to the left (Backspace)
|
||||
if (textbox_select_startpos>0) { // In middle of line, just do string_delete
|
||||
i.line[textbox_select_startline]=string_delete(i.line[textbox_select_startline],textbox_select_startpos,1)
|
||||
textbox_select_startpos-=1
|
||||
i.text=string_delete(i.text,realstartpos,1)
|
||||
} else if (textbox_select_startline>0) { // Else, move up
|
||||
textbox_select_startline-=1
|
||||
textbox_select_startpos=string_length(i.line[textbox_select_startline])
|
||||
if (i.line_wrap[textbox_select_startline+1]) { // If wrapped, delete, otherwise just jump up
|
||||
textbox_select_startpos-=1
|
||||
i.line[textbox_select_startline]=string_copy(i.line[textbox_select_startline],1,textbox_select_startpos)
|
||||
}
|
||||
i.line[textbox_select_startline]=i.line[textbox_select_startline]+i.line[textbox_select_startline+1]
|
||||
i.lines-=1
|
||||
for (l=textbox_select_startline+1 l<i.lines l+=1) {
|
||||
i.line[l]=i.line[l+1]
|
||||
i.line_wrap[l]=i.line_wrap[l+1]
|
||||
i.line_single[l]=i.line_single[l+1]
|
||||
}
|
||||
i.text=string_delete(i.text,realstartpos,1)
|
||||
}
|
||||
} else if (deletetext=-1) { // Delete to right (Delete)
|
||||
if (textbox_select_startpos<string_length(i.line[textbox_select_startline])) {
|
||||
i.line[textbox_select_startline]=string_delete(i.line[textbox_select_startline],textbox_select_startpos+1,1)
|
||||
i.text=string_delete(i.text,realstartpos+1,1)
|
||||
} else if (textbox_select_startline<i.lines-1) {
|
||||
if (i.line_wrap[textbox_select_startline+1]) {
|
||||
i.line[textbox_select_startline+1]=string_delete(i.line[textbox_select_startline+1],1,1) // If wrapped, delete below
|
||||
} else {
|
||||
i.line[textbox_select_startline]+=i.line[textbox_select_startline+1]
|
||||
i.lines-=1
|
||||
for (l=textbox_select_startline+1 l<i.lines l+=1) {
|
||||
i.line[l]=i.line[l+1]
|
||||
i.line_wrap[l]=i.line_wrap[l+1]
|
||||
i.line_single[l]=i.line_single[l+1]
|
||||
}
|
||||
}
|
||||
i.text=string_delete(i.text,realstartpos+1,1)
|
||||
}
|
||||
}
|
||||
}
|
||||
textbox_select_clickline=textbox_select_startline textbox_select_clickpos=textbox_select_startpos
|
||||
textbox_select_mouseline=textbox_select_startline textbox_select_mousepos=textbox_select_startpos
|
||||
textbox_select_endline=textbox_select_startline textbox_select_endpos=textbox_select_startpos
|
||||
}
|
||||
|
||||
// Insert text
|
||||
if (i.max_chars>0) { // Check max limit
|
||||
var maxlen;
|
||||
maxlen=i.max_chars-string_length(i.text);
|
||||
if (string_length(inserttext)>maxlen) inserttext=string_copy(inserttext,1,maxlen)
|
||||
}
|
||||
if (inserttext!="") {
|
||||
textbox_marker=current_time
|
||||
if (i.single_line) inserttext=string_replace_all(inserttext,chr(10)," ")
|
||||
i.text=string_copy(i.text,1,realmousepos)+inserttext+string_delete(i.text,1,realmousepos)
|
||||
|
||||
if (string_pos(chr(10),inserttext)>0) { // Add text with multiple lines (Paste or linebreak)
|
||||
inserttext+=chr(10)
|
||||
a=i.line[textbox_select_mouseline]
|
||||
b=-1
|
||||
while (inserttext!="") { // Parse
|
||||
b+=1
|
||||
str[b]=string_copy(inserttext,1,string_pos(chr(10),inserttext)-1)
|
||||
if (i.replace_char!="") str[b]=string_repeat(i.replace_char,string_length(str[b]))
|
||||
inserttext=string_delete(inserttext,1,string_pos(chr(10),inserttext))
|
||||
}
|
||||
i.lines+=b
|
||||
for (l=i.lines-1 l>=textbox_select_mouseline+b l-=1) { //Push up
|
||||
i.line[l]=i.line[l-b]
|
||||
i.line_wrap[l]=i.line_wrap[l-b]
|
||||
i.line_single[l]=i.line_single[l-b]
|
||||
}
|
||||
for (l=0 l<=b l+=1) { // Insert
|
||||
if (l=0) {
|
||||
i.line[textbox_select_mouseline+l]=string_copy(a,1,textbox_select_mousepos)+str[l] // First
|
||||
i.line_single[textbox_select_mouseline+l]=false
|
||||
} else if (l=b) {
|
||||
i.line[textbox_select_mouseline+l]=str[l]+string_delete(a,1,textbox_select_mousepos) // Last
|
||||
i.line_wrap[textbox_select_mouseline+l]=false
|
||||
} else i.line[textbox_select_mouseline+l]=str[l] // Middle
|
||||
}
|
||||
textbox_select_mouseline+=b
|
||||
textbox_select_mousepos=string_length(str[b])
|
||||
inserttext=" "
|
||||
} else { // Simple insert
|
||||
if (i.replace_char!="") inserttext=string_repeat(i.replace_char,string_length(inserttext))
|
||||
// Apparently, string_insert doesn't support å,ä,ö,é,è,í etc.
|
||||
i.line[textbox_select_startline]=string_copy(i.line[textbox_select_startline],1,textbox_select_mousepos)+inserttext+string_delete(i.line[textbox_select_startline],1,textbox_select_mousepos)
|
||||
textbox_select_mousepos+=string_length(inserttext)
|
||||
}
|
||||
textbox_select_clickline=textbox_select_mouseline textbox_select_clickpos=textbox_select_mousepos
|
||||
textbox_select_startline=textbox_select_mouseline textbox_select_startpos=textbox_select_mousepos
|
||||
textbox_select_endline=textbox_select_mouseline textbox_select_endpos=textbox_select_mousepos
|
||||
}
|
||||
|
||||
// Move screen if text is edited or marker is moved
|
||||
if (inserttext!="" || deletetext!=0 || key_press[vk_left] || key_press[vk_right] || key_press[vk_up] || key_press[vk_down]) {
|
||||
if (i.single_line) {
|
||||
if (textbox_select_mousepos<i.start) i.start=textbox_select_mousepos // Move screen left
|
||||
if (textbox_select_mousepos>i.start+i.chars-1) i.start=textbox_select_mousepos-i.chars // Move screen right
|
||||
} else {
|
||||
if (textbox_select_mouseline<i.start) i.start=textbox_select_mouseline // Move screen up
|
||||
if (textbox_select_mouseline>=i.start+floor(h/lineheight)) i.start=textbox_select_mouseline-floor(h/lineheight)+1 // Move screen down
|
||||
}
|
||||
}
|
||||
|
||||
// Handle selecting
|
||||
if (!mouse_check_button(mb_left)) textbox_select=-1
|
||||
if (textbox_select=i) { // Move up/down if dragging outside of box
|
||||
textbox_marker=current_time
|
||||
if (i.single_line) {
|
||||
if (mouse_x<xx) i.start-=1
|
||||
if (mouse_x>xx+w) i.start+=1
|
||||
} else {
|
||||
if (mouse_y<yy) i.start-=1
|
||||
if (mouse_y>yy+h) i.start+=1
|
||||
}
|
||||
}
|
||||
if (textbox_click>0) {
|
||||
if (textbox_select_mouseline=textbox_select_clickline) {
|
||||
textbox_select_startline=textbox_select_mouseline
|
||||
textbox_select_endline=textbox_select_mouseline
|
||||
if (textbox_select_mousepos>=textbox_select_clickpos) {
|
||||
textbox_select_startpos=textbox_select_clickpos
|
||||
textbox_select_endpos=textbox_select_mousepos
|
||||
} else {
|
||||
textbox_select_startpos=textbox_select_mousepos
|
||||
textbox_select_endpos=textbox_select_clickpos
|
||||
}
|
||||
}
|
||||
if (textbox_select_mouseline>textbox_select_clickline) {
|
||||
textbox_select_startline=textbox_select_clickline
|
||||
textbox_select_startpos=textbox_select_clickpos
|
||||
textbox_select_endline=textbox_select_mouseline
|
||||
textbox_select_endpos=textbox_select_mousepos
|
||||
}
|
||||
if (textbox_select_mouseline<textbox_select_clickline) {
|
||||
textbox_select_startline=textbox_select_mouseline
|
||||
textbox_select_startpos=textbox_select_mousepos
|
||||
textbox_select_endline=textbox_select_clickline
|
||||
textbox_select_endpos=textbox_select_clickpos
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (i.single_line) { // Calculate the amount of characters visible
|
||||
// Avoid negative start character
|
||||
i.start=max(0,i.start)
|
||||
// Find minimum position
|
||||
ww=0
|
||||
for (a=string_length(i.line[0]) a>=0 a-=1) {
|
||||
ww+=string_width(string_replace(string_char_at(i.line[0],a),"#","\#"))
|
||||
b=a
|
||||
if (ww>w) break
|
||||
}
|
||||
i.start=min(b,i.start)
|
||||
// Calculate visible
|
||||
ww=0
|
||||
i.chars=0
|
||||
for (a=i.start+1 a<=string_length(i.line[0]) a+=1) {
|
||||
ww+=string_width(string_replace(string_char_at(i.line[0],a),"#","\#"))
|
||||
if (ww>w) break
|
||||
i.chars+=1
|
||||
}
|
||||
} else { // Wordwrapping
|
||||
if (changetext || i.last_width!=w || inserttext!="" || deletetext!=0) { // Detect box width or line length changes.
|
||||
for (l=1 l<i.lines l+=1) { // Move words up?
|
||||
ww=string_width(string_replace_all(i.line[l-1],"#","\#"))
|
||||
if (!i.line_wrap[l] || ww>w) continue
|
||||
if (i.line_single[l-1]) { // Single-worded line
|
||||
for (p=1 p<=string_length(i.line[l]) p+=1) { // Try to add remaining letters
|
||||
if (ww+string_width(string_replace_all(string_copy(i.line[l],1,p),"#","\#"))>w) break
|
||||
a=string_char_at(i.line[l],p+1)
|
||||
if (a=" " || a="-") {
|
||||
p+=1
|
||||
i.line_single[l-1]=false
|
||||
break
|
||||
}
|
||||
if (p=string_length(i.line[l]) && !i.line_single[l]) i.line_single[l-1]=false
|
||||
}
|
||||
if (p=1) continue //Cannot move up
|
||||
a=string_length(i.line[l-1]) // Move markers if affected
|
||||
if (textbox_select_mouseline=l && textbox_select_mousepos<=p) {textbox_select_mouseline-=1 textbox_select_mousepos+=a}
|
||||
if (textbox_select_clickline=l && textbox_select_clickpos<=p) {textbox_select_clickline-=1 textbox_select_clickpos+=a}
|
||||
if (textbox_select_endline=l && textbox_select_endpos<=p) {textbox_select_endline-=1 textbox_select_endpos+=a}
|
||||
if (textbox_select_startline=l && textbox_select_startpos<=p) {textbox_select_startline-=1 textbox_select_startpos+=a}
|
||||
if (textbox_select_mouseline=l) textbox_select_mousepos-=p
|
||||
if (textbox_select_clickline=l) textbox_select_clickpos-=p
|
||||
if (textbox_select_endline=l) textbox_select_endpos-=p
|
||||
if (textbox_select_startline=l) textbox_select_startpos-=p
|
||||
i.line[l-1]+=string_copy(i.line[l],1,p)
|
||||
i.line[l]=string_delete(i.line[l],1,p)
|
||||
}
|
||||
while (i.line[l]!="") { // Try to add words
|
||||
p=string_pos(" ",i.line[l])
|
||||
if (p=0) p=string_pos("-",i.line[l])
|
||||
if (p=0) p=string_length(i.line[l])
|
||||
if (ww+string_width(string_replace_all(string_copy(i.line[l],1,p-1),"#","\#"))>w) break
|
||||
a=string_length(i.line[l-1]) // Move markers if affected
|
||||
if (textbox_select_mouseline=l && textbox_select_mousepos<=p) {textbox_select_mouseline-=1 textbox_select_mousepos+=a}
|
||||
if (textbox_select_clickline=l && textbox_select_clickpos<=p) {textbox_select_clickline-=1 textbox_select_clickpos+=a}
|
||||
if (textbox_select_endline=l && textbox_select_endpos<=p) {textbox_select_endline-=1 textbox_select_endpos+=a}
|
||||
if (textbox_select_startline=l && textbox_select_startpos<=p) {textbox_select_startline-=1 textbox_select_startpos+=a}
|
||||
if (textbox_select_mouseline=l) textbox_select_mousepos-=p
|
||||
if (textbox_select_clickline=l) textbox_select_clickpos-=p
|
||||
if (textbox_select_endline=l) textbox_select_endpos-=p
|
||||
if (textbox_select_startline=l) textbox_select_startpos-=p
|
||||
i.line[l-1]+=string_copy(i.line[l],1,p)
|
||||
i.line[l]=string_delete(i.line[l],1,p)
|
||||
}
|
||||
|
||||
if (i.line[l]="") { // Remove empty line
|
||||
i.lines-=1
|
||||
for (a=l a<i.lines a+=1) {
|
||||
i.line[a]=i.line[a+1]
|
||||
i.line_wrap[a]=i.line_wrap[a+1]
|
||||
i.line_single[a]=i.line_single[a+1]
|
||||
if (textbox_select_mouseline=a+1) textbox_select_mouseline-=1 // Move markers if affected
|
||||
if (textbox_select_clickline=a+1) textbox_select_clickline-=1
|
||||
if (textbox_select_endline=a+1) textbox_select_endline-=1
|
||||
if (textbox_select_startline=a+1) textbox_select_startline-=1
|
||||
}
|
||||
l-=1
|
||||
}
|
||||
}
|
||||
for (l=0 l<i.lines l+=1) { // Move words down?
|
||||
if (string_width(string_replace_all(i.line[l],"#","\#"))>w) {
|
||||
i.line_single[l]=false
|
||||
for (p=string_length(i.line[l]) p>1 p-=1) { // Look for words
|
||||
a=string_char_at(i.line[l],p)
|
||||
if (a=" " || a="-") {
|
||||
if (string_width(string_replace_all(string_copy(i.line[l],1,p-1),"#","\#"))<w) break
|
||||
}
|
||||
}
|
||||
if (p=1) { // Single-word line found
|
||||
i.line_single[l]=true
|
||||
for (p=string_length(i.line[l])-1 p>1 p-=1) {
|
||||
if (string_width(string_replace_all(string_copy(i.line[l],1,p),"#","\#"))<w) break
|
||||
}
|
||||
}
|
||||
if (p=0) continue // Cannot be wrapped
|
||||
if (l=i.lines-1) a=true
|
||||
else a=!i.line_wrap[l+1]
|
||||
if (a) { // Create new line for wrapped text
|
||||
for (b=i.lines b>l b-=1) { // Push
|
||||
i.line[b]=i.line[b-1]
|
||||
i.line_wrap[b]=i.line_wrap[b-1]
|
||||
i.line_single[b]=i.line_single[b-1]
|
||||
if (textbox_select_mouseline=b) textbox_select_mouseline+=1 //Move markers if affected
|
||||
if (textbox_select_clickline=b) textbox_select_clickline+=1
|
||||
if (textbox_select_endline=b) textbox_select_endline+=1
|
||||
if (textbox_select_startline=b) textbox_select_startline+=1
|
||||
}
|
||||
i.lines+=1
|
||||
i.line[l+1]=string_delete(i.line[l],1,p)
|
||||
i.line_wrap[l+1]=true
|
||||
i.line_single[l+1]=false
|
||||
} else {
|
||||
i.line[l+1]=string_delete(i.line[l],1,p)+i.line[l+1] // Add to existing
|
||||
}
|
||||
// Move markers if affected
|
||||
a=string_length(i.line[l])-p
|
||||
if (textbox_select_mouseline=l+1) textbox_select_mousepos+=a
|
||||
if (textbox_select_clickline=l+1) textbox_select_clickpos+=a
|
||||
if (textbox_select_endline=l+1) textbox_select_endpos+=a
|
||||
if (textbox_select_startline=l+1) textbox_select_startpos+=a
|
||||
if (textbox_select_mouseline=l && textbox_select_mousepos>=p) {textbox_select_mouseline+=1 textbox_select_mousepos-=p}
|
||||
if (textbox_select_clickline=l && textbox_select_clickpos>=p) {textbox_select_clickline+=1 textbox_select_clickpos-=p}
|
||||
if (textbox_select_endline=l && textbox_select_endpos>=p) {textbox_select_endline+=1 textbox_select_endpos-=p}
|
||||
if (textbox_select_startline=l && textbox_select_startpos>=p) {textbox_select_startline+=1 textbox_select_startpos-=p}
|
||||
i.line[l]=string_copy(i.line[l],1,p)
|
||||
}
|
||||
}
|
||||
if (textbox_select_mouseline<i.start) i.start=textbox_select_mouseline // Move screen up
|
||||
if (textbox_select_mouseline>=i.start+floor(h/lineheight)) i.start=textbox_select_mouseline-floor(h/lineheight)+1 // Move screen down
|
||||
}
|
||||
i.start=max(0,min(i.start,i.lines-floor(h/lineheight)))
|
||||
}
|
||||
|
||||
//Draw text and selection
|
||||
draw_set_halign(fa_left)
|
||||
draw_set_valign(fa_top)
|
||||
for (l=i.start*!i.single_line l<i.lines l+=1) {
|
||||
var ly;
|
||||
ly=(l-i.start*!i.single_line)*lineheight; // Current line y value
|
||||
if (ly+lineheight>h) break // Exit if beyond box
|
||||
if ((mouseover && textbox_select=-1) || textbox_select=i) {
|
||||
if (l=i.lines-1) hh=h-ly
|
||||
else hh=lineheight
|
||||
if ((mouse_x>=xx || textbox_select=i) &&
|
||||
(mouse_x<xx+w || textbox_select=i) &&
|
||||
(mouse_y>=yy+ly || (textbox_select=i && ly=0)) &&
|
||||
(mouse_y<yy+ly+hh || (textbox_select=i && (ly+lineheight>h || l=i.lines-1)))) { // Cursor is inside line
|
||||
if (mouse_check_button(mb_left)) {
|
||||
if (i.select_on_focus && textbox_lastfocus!=i) { // Select all
|
||||
textbox_select_startline=0 textbox_select_startpos=0
|
||||
textbox_select_endline=i.lines-1 textbox_select_endpos=string_length(i.line[textbox_select_endline])
|
||||
textbox_select_mouseline=textbox_select_endline textbox_select_mousepos=textbox_select_endpos
|
||||
textbox_select_clickline=0 textbox_select_clickpos=0
|
||||
textbox_marker=current_time
|
||||
textbox_focus=i
|
||||
keyboard_string=""
|
||||
mouse_clear(mb_left)
|
||||
} else {
|
||||
textbox_select=i
|
||||
ww=0
|
||||
for (a=i.start*i.single_line a<string_length(i.line[l]) a+=1) { // Find character over mouse
|
||||
b=string_width(string_replace(string_char_at(i.line[l],a+1),"#","\#"))
|
||||
ww+=b
|
||||
if (mouse_x<xx+ww-b/2) break
|
||||
}
|
||||
textbox_select_mouseline=l
|
||||
textbox_select_mousepos=a
|
||||
if (mouse_check_button_pressed(mb_left)) {
|
||||
if (textbox_select_clickline=textbox_select_mouseline && textbox_select_clickpos=textbox_select_mousepos) { // Double click, word select
|
||||
if (current_time-textbox_click<500) {
|
||||
textbox_select_startline=textbox_select_mouseline textbox_select_startpos=max(1,textbox_select_mousepos-1)
|
||||
textbox_select_endline=textbox_select_mouseline textbox_select_endpos=max(1,textbox_select_mousepos)
|
||||
while (1) { // Look left/up for start position
|
||||
c=string_char_at(i.line[textbox_select_startline],textbox_select_startpos)
|
||||
if (c=" " || c="," || c="(" || c=")" || c="[" || c="]" || c="+") break
|
||||
textbox_select_startpos-=1
|
||||
if (textbox_select_startpos<=0) { // Jump up a line if it's a single word
|
||||
if (textbox_select_startline=0) break
|
||||
if (!i.line_single[textbox_select_startline-1]) break
|
||||
textbox_select_startline-=1
|
||||
textbox_select_startpos=string_length(i.line[textbox_select_startline])
|
||||
}
|
||||
if (textbox_select_startpos<=0) break
|
||||
}
|
||||
while (1) { // Look right/down for end position
|
||||
c=string_char_at(i.line[textbox_select_endline],textbox_select_endpos)
|
||||
if (c=" " || c="," || c="(" || c=")" || c="[" || c="]" || c="+") break
|
||||
textbox_select_endpos+=1
|
||||
if (textbox_select_endpos>=string_length(i.line[textbox_select_endline])) {
|
||||
if (textbox_select_endline=i.lines-1) break
|
||||
if (!i.line_single[textbox_select_endline]) break
|
||||
textbox_select_endline+=1
|
||||
textbox_select_endpos=0
|
||||
}
|
||||
if (textbox_select_endpos>=string_length(i.line[textbox_select_endline])) break
|
||||
}
|
||||
textbox_select_mouseline=textbox_select_endline
|
||||
textbox_select_mousepos=textbox_select_endpos
|
||||
textbox_click=0
|
||||
mouse_clear(mb_left)
|
||||
} else { // Remove selection if clicking after word select
|
||||
textbox_click=current_time
|
||||
textbox_select_startline=textbox_select_mouseline textbox_select_startpos=textbox_select_mousepos
|
||||
textbox_select_endline=textbox_select_mouseline textbox_select_endpos=textbox_select_mousepos
|
||||
}
|
||||
} else {
|
||||
textbox_click=current_time
|
||||
if (!keyboard_check(vk_shift) || textbox_lastfocus!=i) { // Drag selection if shift is held
|
||||
textbox_select_startline=textbox_select_mouseline textbox_select_startpos=textbox_select_mousepos
|
||||
textbox_select_endline=textbox_select_mouseline textbox_select_endpos=textbox_select_mousepos
|
||||
textbox_select_clickline=textbox_select_mouseline textbox_select_clickpos=textbox_select_mousepos
|
||||
}
|
||||
}
|
||||
textbox_marker=current_time
|
||||
textbox_focus=i
|
||||
keyboard_string=""
|
||||
textbox_lastfocus=i
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i.single_line) {
|
||||
if (textbox_focus=i && textbox_select_startpos!=textbox_select_endpos) {
|
||||
for (a=0 a<3 a+=1) str[a]=""
|
||||
if (textbox_select_endpos<i.start+1 || textbox_select_startpos>i.start+1+i.chars) str[0]=string_copy(i.line[0],i.start+1,i.chars) // Selection is outside
|
||||
else if (textbox_select_startpos<=i.start && textbox_select_endpos>i.start+i.chars) str[1]=string_copy(i.line[0],i.start+1,i.chars) // All visible is selected
|
||||
else if (textbox_select_startpos>i.start && textbox_select_endpos<i.start+i.chars) { // Only a part of visible is selected
|
||||
str[0]=string_copy(i.line[0],i.start+1,textbox_select_startpos-i.start)
|
||||
str[1]=string_copy(i.line[0],textbox_select_startpos+1,textbox_select_endpos-textbox_select_startpos)
|
||||
str[2]=string_copy(i.line[0],textbox_select_endpos+1,i.start+i.chars-textbox_select_endpos)
|
||||
} else if (textbox_select_startpos<=i.start) { // Beginning is to the left
|
||||
str[1]=string_copy(i.line[0],i.start+1,textbox_select_endpos-i.start)
|
||||
str[2]=string_copy(i.line[0],textbox_select_endpos+1,i.start+i.chars-textbox_select_endpos)
|
||||
} else { // Ending is to the right
|
||||
str[0]=string_copy(i.line[0],i.start+1,textbox_select_startpos-i.start)
|
||||
str[1]=string_copy(i.line[0],textbox_select_startpos+1,i.start+i.chars-textbox_select_startpos)
|
||||
}
|
||||
for (a=0 a<3 a+=1) str[a]=string_replace_all(str[a],"#","\#")
|
||||
if (str[0]!="") { // Text before or outside selection
|
||||
draw_set_color(color_normal)
|
||||
draw_text(xx,yy,str[0])
|
||||
}
|
||||
if (str[1]!="") { // Selected text
|
||||
draw_set_color(color_selection)
|
||||
draw_rectangle(min(xx+w,xx+string_width(str[0])),yy,min(xx+w,xx+string_width(str[0]+str[1])),yy+lineheight-1,0)
|
||||
draw_set_color(color_selected)
|
||||
draw_text(xx+string_width(str[0]),yy,str[1])
|
||||
}
|
||||
if (str[2]!="") { // Text after selection
|
||||
draw_set_color(color_normal)
|
||||
draw_text(xx+string_width(str[0]+str[1]),yy,str[2])
|
||||
}
|
||||
} else { // Unselected
|
||||
draw_set_color(color_normal)
|
||||
draw_text(xx,yy,string_replace_all(string_copy(i.line[0],i.start+1,i.chars),"#","\#"))
|
||||
}
|
||||
} else {
|
||||
if (textbox_focus=i && (textbox_select_startline!=textbox_select_endline || textbox_select_startpos!=textbox_select_endpos)) { // This line is selected
|
||||
for (a=0 a<3 a+=1) str[a]=""
|
||||
if (textbox_select_startline=l && textbox_select_endline=l) { // Same line
|
||||
str[0]=string_copy(i.line[l],1,textbox_select_startpos)
|
||||
str[1]=string_copy(i.line[l],textbox_select_startpos+1,textbox_select_endpos-textbox_select_startpos)
|
||||
str[2]=string_delete(i.line[l],1,textbox_select_endpos)
|
||||
} else if (textbox_select_startline=l) { // Beginning line
|
||||
str[0]=string_copy(i.line[l],1,textbox_select_startpos)
|
||||
str[1]=string_delete(i.line[l],1,textbox_select_startpos)
|
||||
} else if (textbox_select_endline=l) { // Ending line
|
||||
str[1]=string_copy(i.line[l],1,textbox_select_endpos)
|
||||
str[2]=string_delete(i.line[l],1,textbox_select_endpos)
|
||||
} else if (textbox_select_startline<l && textbox_select_endline>l) { // Between
|
||||
str[1]=i.line[l]
|
||||
} else { // Outside
|
||||
str[0]=i.line[l]
|
||||
}
|
||||
for (a=0 a<3 a+=1) str[a]=string_replace_all(str[a],"#","\#")
|
||||
if (str[0]!="") { // Text before or outside selection
|
||||
draw_set_color(color_normal)
|
||||
draw_text(xx,yy+ly,str[0])
|
||||
}
|
||||
if (str[1]!="") { // Selected text
|
||||
draw_set_color(color_selection)
|
||||
draw_rectangle(min(xx+w,xx+string_width(str[0])),yy+ly,min(xx+w,xx+string_width(str[0]+str[1])),yy+ly+lineheight-1,0)
|
||||
draw_set_color(color_selected)
|
||||
draw_text(xx+string_width(str[0]),yy+ly,str[1])
|
||||
}
|
||||
if (str[2]!="") { // Text after selection
|
||||
draw_set_color(color_normal)
|
||||
draw_text(xx+string_width(str[0]+str[1]),yy+ly,str[2])
|
||||
}
|
||||
} else { // Unselected line
|
||||
draw_set_color(color_normal)
|
||||
draw_text(xx,yy+ly,string_replace_all(i.line[l],"#","\#"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Marker
|
||||
if (textbox_focus=i && !i.read_only) {
|
||||
a=string_width(string_replace_all(string_copy(i.line[textbox_select_mouseline],1,textbox_select_mousepos),"#","\#"))
|
||||
b=(textbox_select_mouseline-i.start)*lineheight
|
||||
if (i.single_line) {
|
||||
a-=string_width(string_replace_all(string_copy(i.line[textbox_select_mouseline],1,i.start),"#","\#"))
|
||||
b=0
|
||||
}
|
||||
if (a>=0 && a<=w && b>=0 && b+lineheight<=h && (current_time-textbox_marker) mod 1000<500) {
|
||||
draw_set_color(color_marker)
|
||||
draw_line(xx+a+1,yy+b-1,xx+a+1,yy+b+lineheight-1)
|
||||
}
|
||||
}
|
||||
|
||||
if (textbox_focus=i) textbox_lastfocus=i
|
||||
else if (textbox_focus=-1) textbox_lastfocus=-1
|
||||
|
||||
// Set cursor
|
||||
if (mouseover || textbox_select=i) {
|
||||
textbox_mouseover=i
|
||||
window_set_cursor(cr_beam)
|
||||
} else if (textbox_mouseover=i) {
|
||||
textbox_mouseover=-1
|
||||
window_set_cursor(cr_default)
|
||||
}
|
||||
i.last_text=i.text
|
||||
i.last_width=w
|
||||
|
||||
draw_set_color(color_normal)
|
||||
return i.text
|
||||
}
|
7
src/Scripts/_resources.list.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="General" type="GROUP"/>
|
||||
<resource name="Textbox" type="GROUP"/>
|
||||
<resource name="Scrollbars" type="GROUP"/>
|
||||
<resource name="IRC Functions" type="GROUP"/>
|
||||
</resources>
|
2
src/Sounds/_resources.list.xml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources/>
|
6
src/Sprites/Fonts/_resources.list.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<resources>
|
||||
<resource name="sprGameSystem" type="RESOURCE"/>
|
||||
<resource name="sprCyberspace" type="RESOURCE"/>
|
||||
<resource name="sprRomulus" type="RESOURCE"/>
|
||||
</resources>
|
BIN
src/Sprites/Fonts/sprCyberspace.images/image 0.png
Normal file
After Width: | Height: | Size: 70 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 1.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 10.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 11.png
Normal file
After Width: | Height: | Size: 92 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 12.png
Normal file
After Width: | Height: | Size: 81 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 13.png
Normal file
After Width: | Height: | Size: 76 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 14.png
Normal file
After Width: | Height: | Size: 79 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 15.png
Normal file
After Width: | Height: | Size: 83 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 16.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 17.png
Normal file
After Width: | Height: | Size: 83 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 18.png
Normal file
After Width: | Height: | Size: 96 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 19.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 2.png
Normal file
After Width: | Height: | Size: 86 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 20.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 21.png
Normal file
After Width: | Height: | Size: 92 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 22.png
Normal file
After Width: | Height: | Size: 96 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 23.png
Normal file
After Width: | Height: | Size: 80 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 24.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 25.png
Normal file
After Width: | Height: | Size: 86 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 26.png
Normal file
After Width: | Height: | Size: 85 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 27.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 28.png
Normal file
After Width: | Height: | Size: 82 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 29.png
Normal file
After Width: | Height: | Size: 83 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 3.png
Normal file
After Width: | Height: | Size: 90 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 30.png
Normal file
After Width: | Height: | Size: 81 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 31.png
Normal file
After Width: | Height: | Size: 86 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 32.png
Normal file
After Width: | Height: | Size: 105 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 33.png
Normal file
After Width: | Height: | Size: 96 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 34.png
Normal file
After Width: | Height: | Size: 93 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 35.png
Normal file
After Width: | Height: | Size: 94 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 36.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 37.png
Normal file
After Width: | Height: | Size: 92 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 38.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 39.png
Normal file
After Width: | Height: | Size: 96 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 4.png
Normal file
After Width: | Height: | Size: 102 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 40.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 41.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 42.png
Normal file
After Width: | Height: | Size: 92 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 43.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 44.png
Normal file
After Width: | Height: | Size: 84 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 45.png
Normal file
After Width: | Height: | Size: 87 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 46.png
Normal file
After Width: | Height: | Size: 83 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 47.png
Normal file
After Width: | Height: | Size: 86 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 48.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 49.png
Normal file
After Width: | Height: | Size: 88 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 5.png
Normal file
After Width: | Height: | Size: 100 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 50.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 51.png
Normal file
After Width: | Height: | Size: 98 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 52.png
Normal file
After Width: | Height: | Size: 84 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 53.png
Normal file
After Width: | Height: | Size: 86 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 54.png
Normal file
After Width: | Height: | Size: 99 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 55.png
Normal file
After Width: | Height: | Size: 89 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 56.png
Normal file
After Width: | Height: | Size: 97 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 57.png
Normal file
After Width: | Height: | Size: 92 B |
BIN
src/Sprites/Fonts/sprCyberspace.images/image 58.png
Normal file
After Width: | Height: | Size: 100 B |