// auto-transcompiled — see *.dnd.json for canonical truth
if(!instance_exists(iv_backdraw))
{



if(global.selectid == 0)
{

if(global.mb_level == 0)
{
global.mbout = 0;
instance_destroy();
}
else if(global.mb_level == 1 || global.mb_level == 3)
{
if(global.mb_level != 1) keyboard_string = "";
global.mb_level = 0;
}
else if(global.mb_level == 2 || global.mb_level == 4 || global.mb_level == 5 || global.mb_level == 6)
{
if(global.mb_level != 2) keyboard_string = "";
global.mb_level = 1;
}

}


else if(global.selectid == 1)
{

if(global.mb_level == 0)
{
global.rselectid = 0;
global.mb_ctopic = global.mb_ctindex[global.tselectid+global.mbttopline];
global.mbrtopline = global.mb_topic[global.mb_ctopic,1]-1;
global.mb_level = 1;
}
else if(global.mb_level == 1)
{
if(global.rselectid > 0)
{
global.mb_creply = global.mbrtopline-(global.rselectid-1);
}
global.mb_level = 2;
}
else if(global.mb_level == 2)
{
event_perform(ev_other,ev_user0);
}
else if(global.mb_level == 3)
{
global.mb_topic[global.mb_total[1],0] = global.playername + "[" + global.mb_ntemptitle + "]" + global.mb_ntempbody;
global.mb_topic[global.mb_total[1],2] = global.mb_cboard;
//Send this new topic to the server:
clearbuffer();
writebyte(11);
writeint(global.mb_cboard);
writestring(global.mb_topic[global.mb_total[1],0]);
sendmessage(global.s_tcpsocket);
global.mb_total[1] += 1;
keyboard_string = "";
global.tselectid = 0;
global.mbttopline = -1;
global.mb_level = 0;
}
else if(global.mb_level == 4)
{
global.mb_reply[global.mb_ctopic,global.mb_topic[global.mb_ctopic,1]] = global.playername + "[" + global.mb_ntemptitle + "]" + global.mb_ntempbody;
//Send this new reply to the server:
clearbuffer();
writebyte(12);
writeint(global.mb_ctopic);
writestring(global.mb_reply[global.mb_ctopic,global.mb_topic[global.mb_ctopic,1]]);
sendmessage(global.s_tcpsocket);
global.mb_topic[global.mb_ctopic,1] += 1;
keyboard_string = "";
global.rselectid = 0;
global.mbrtopline = global.mb_topic[global.mb_ctopic,1]-1;
global.mb_ctopic = mb_trise(global.mb_ctopic);
global.mb_level = 1;
}
else if(global.mb_level == 5)
{
global.mb_topic[global.mb_ctopic,0] = mb_getwriter(global.mb_topic[global.mb_ctopic,0]) + "[" + global.mb_ntemptitle + "]" + global.mb_ntempbody;
//global.mb_topic[global.mb_ctopic,2] = global.mb_cboard;
//Send the editted topic to the server:
clearbuffer();
writebyte(6);
writeint(global.mb_ctopic);
writestring(global.mb_topic[global.mb_ctopic,0]);
sendmessage(global.s_tcpsocket);
keyboard_string = "";
global.mb_level = 1;
}
else if(global.mb_level == 6)
{
global.mb_reply[global.mb_ctopic,global.mb_creply] = mb_getwriter(global.mb_reply[global.mb_ctopic,global.mb_creply]) + "[" + global.mb_ntemptitle + "]" + global.mb_ntempbody;
//Send the editted reply to the server:
clearbuffer();
writebyte(7);
writeint(global.mb_ctopic);
writeint(global.mb_creply);
writestring(global.mb_reply[global.mb_ctopic,global.mb_creply]);
sendmessage(global.s_tcpsocket);
keyboard_string = "";
global.mb_level = 1;
}

}


else if(global.selectid == 2)
{

if(global.mb_level == 0)
{
global.mb_level = 3;
global.nselectid = 0;
keyboard_string = "Enter Topic Title";
global.mb_ntempbody = "Enter the topic's body text.";
}
else if(global.mb_level == 1)
{
global.mb_level = 4;
global.nselectid = 0;
keyboard_string = "Enter Reply Title";
global.mb_ntempbody = "Enter the reply's body text.";
}
else if(global.mb_level == 2)
{
clipboard_set_text(global.mb_creplytext);
if(global.rselectid > 0)
{
caddline("The topic reply titled '" + mb_getname(global.mb_reply[global.mb_ctopic,global.mb_creply]) + "', written by " + mb_getwriter(global.mb_reply[global.mb_ctopic,global.mb_creply]) + ", has been copied to your clipboard.",global.c_server);
}
else
{
caddline("The topic message titled '" + mb_getname(global.mb_topic[global.mb_ctopic,0]) + "', written by " + mb_getwriter(global.mb_topic[global.mb_ctopic,0]) + ", has been copied to your clipboard.",global.c_server);
}
}
else if(global.mb_level == 5)
{
//Delete this topic:
clearbuffer();
writebyte(19);
writebyte(0);
writeint(global.mb_ctopic);
sendmessage(global.s_tcpsocket);
keyboard_string = "";
global.mb_level = 0;
mb_tcollapse(global.mb_ctopic);
//Send a request for a board string and topic update for this board:
clearbuffer();
writebyte(13);
writebyte(global.clientid);
writeint(global.mb_cboard);
sendmessage(global.s_tcpsocket);
}
else if(global.mb_level == 6)
{
//Delete this reply:
clearbuffer();
writebyte(19);
writebyte(1);
writeint(global.mb_ctopic);
writeint(global.mb_creply);
sendmessage(global.s_tcpsocket);
keyboard_string = "";
global.mb_level = 1;
mb_rcollapse(global.mb_ctopic,global.mb_creply);
//Send a request for a topic replies update:
clearbuffer();
writebyte(14);
writeint(global.mb_ctopic);
sendmessage(global.s_tcpsocket);
}

}


else if(global.selectid == 3)
{

if(global.mb_level == 0)
{
//Send a request for a board string and topic update for this board:
clearbuffer();
writebyte(13);
writeint(global.mb_cboard);
sendmessage(global.s_tcpsocket);
}
else if(global.mb_level == 1)
{
//Send a request for a topic replies update:
clearbuffer();
writebyte(14);
writeint(global.mb_ctopic);
sendmessage(global.s_tcpsocket);
}
else if(global.mb_level == 2)
{

global.nselectid = 1;
keyboard_string = global.mb_creplytext;
global.mb_ntempbody = global.mb_creplytext;
if(global.rselectid == 0)
{
global.mb_ntemptitle = mb_getname(global.mb_topic[global.mb_ctopic,0]);
global.mb_level = 5;
}
else
{
global.mb_ntemptitle = mb_getname(global.mb_reply[global.mb_ctopic,global.mb_creply]);
global.mb_level = 6;
}

}

}



if(global.mb_level == 0)
{
//Send a request for a board string and topic update for this board:
clearbuffer();
writebyte(13);
writeint(global.mb_cboard);
sendmessage(global.s_tcpsocket);
global.selectid = 1;
global.cselmax = 4;
selectiontext[0] = "Leave Board";
selectiontext[1] = "View Topic";
selectiontext[2] = "New Topic";
selectiontext[3] = "Refresh";
}
else if(global.mb_level == 1)
{
//Send a request for a topic replies update:
clearbuffer();
writebyte(14);
writeint(global.mb_ctopic);
sendmessage(global.s_tcpsocket);
global.selectid = 1;
global.cselmax = 4;
selectiontext[0] = "Back to Topics";
selectiontext[1] = "Show Post";
selectiontext[2] = "New Reply";
selectiontext[3] = "Refresh";
}
else if(global.mb_level == 2)
{
global.selectid = 0;
if((mb_getwriter(global.mb_topic[global.mb_ctopic,0]) == global.playername && global.rselectid == 0) ||
   (mb_getwriter(global.mb_reply[global.mb_ctopic,global.mb_creply]) == global.playername && global.rselectid > 0) ||
    mb_getwriter(global.mb_board[global.mb_cboard]) == global.playername || iv_itemsearch(1,"907") > 0)
global.cselmax = 4;
else global.cselmax = 3;
selectiontext[0] = "Back to Replies";
selectiontext[1] = "Go To A Link";
selectiontext[2] = "Copy Post";
selectiontext[3] = "Edit Post";
}
else if(global.mb_level == 3)
{
global.selectid = 1;
global.cselmax = 2;
selectiontext[0] = "Cancel Post";
selectiontext[1] = "Post Topic";
}
else if(global.mb_level == 4)
{
global.selectid = 1;
global.cselmax = 2;
selectiontext[0] = "Cancel Post";
selectiontext[1] = "Post Reply";
}
else if(global.mb_level == 5)
{
global.selectid = 1;
global.cselmax = 3;
selectiontext[0] = "Cancel Edit";
selectiontext[1] = "Submit Changes";
selectiontext[2] = "Delete Topic";
}
else if(global.mb_level == 6)
{
global.selectid = 1;
global.cselmax = 3;
selectiontext[0] = "Cancel Edit";
selectiontext[1] = "Submit Changes";
selectiontext[2] = "Delete Reply";
}



}
