#include "scripts\base.inc"
#include "scripts\keys.inc"
global Name3Calling;
var NumLines = 7;
var CurrentMode = ""; // none, number, contact, sms, menu, singlesms
var CurrentItems;
var ScrollOffset = 0;
var CurrentNumber = "";
var MenuOn = false;
var MenuItems;
var NumberItems;
var SmsItems;
var CurrentSms;
var CurrentContact;
var CallCancelled = false;
var RingCounter = 0;
//these controls the visibility of the entity containers which contain the "mode" background images
var ContactsBackground =
this.
GetControl("contacts_background");
var NumberBackground =
this.
GetControl("number_background");
var MessagesBackground =
this.
GetControl("messages_background");
var SingleMessageBackground =
this.
GetControl("single_message_background");
var ContactInfoBackground =
this.
GetControl("contact_info_background");
var InCallBackground =
this.
GetControl("in_call_background");
var IncomingCallBackground =
this.
GetControl("incoming_call_background");
var CallCancellingBackground =
this.
GetControl("call_cancelling_background");
var MenuBackground =
this.
GetControl("menu_background");
// define main menu
AddMenu("Address book");
AddMenu("Text messages");
// define address book
AddNumber("Home", "123456789", "home");
AddNumber("Mom", "0987654321", "mom");
AddNumber("Name3", "988609099", "name3");
AddNumber("Name4", "349386743", "name4");
// define SMS
AddSms("Mom", "Hi there, come", "visit me sometime,", "would you?");
AddSms("Name3", "Hi there. I'm 3, Name 3. Fear me!!!");
//what to do when the phone is ringing
if(Name3Calling==1) //controls which conversation to have when we accept the call
{
ClearDisplay();
SetMode("incoming_call");
SetLine(3, "Incoming call...", false, true);
SetLine(4, "Name3", false, true);
}
else SetMode("none");
////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
var Btn = null;
if(Btn==null)
{
}
if(Btn!=
null) Btn.
Press();
}
on "0" OnKey("0");
on "1" OnKey("1");
on "2" OnKey("2");
on "3" OnKey("3");
on "4" OnKey("4");
on "5" OnKey("5");
on "6" OnKey("6");
on "7" OnKey("7");
on "8" OnKey("8");
on "9" OnKey("9");
on "*" OnKey("*");
on "#" OnKey("#");
////////////////////////////////////////////////////////////////////////////////
on "action"
{
if(CurrentMode=="none") SetMode("menu");
else if(CurrentMode=="menu")
{
{
case 0:
SetMode("contact");
break;
case 1:
SetMode("sms");
break;
}
}
else if(CurrentMode=="sms")
{
ContainersInvisible();
SetMode("singlesms");
}
else if(CurrentMode=="contact")
{
}
else if(CurrentMode=="contact_info")
{
CallContact(CurrentContact);
}
else if(CurrentMode=="number")
{
CallNumber(CurrentNumber);
}
else if(CurrentMode=="incoming_call")
{
SetMode("in_call");
}
}
////////////////////////////////////////////////////////////////////////////////
on "right_option"
{
if(CurrentMode=="none")
{
SetMode("contact");
}
else if(CurrentMode=="menu")
{
ContainersInvisible();
SetMode("none");
}
else if(CurrentMode=="contact")
{
ContainersInvisible();
if(MenuOn==true) SetMode("menu");
else SetMode("none");
}
else if(CurrentMode=="sms")
{
ContainersInvisible();
if(MenuOn==true) SetMode("menu");
else SetMode("none");
}
else if(CurrentMode=="singlesms")
{
ContainersInvisible();
SetMode("sms");
}
else if(CurrentMode=="number")
{
{
ContainersInvisible();
SetMode("none");
}
else
{
var Str =
new String(CurrentNumber
);
SetLine(6, CurrentNumber, false, false, true);
}
}
else if(CurrentMode=="contact_info")
{
ContainersInvisible();
SetMode("contact");
}
else if(CurrentMode=="incoming_call")
{
actor.
Talk("I'd better answer. It could be important.");
}
else if(CurrentMode=="in_call")
{
CallCancelled = true;
SetMode("call_cancelling");
}
}
////////////////////////////////////////////////////////////////////////////////
on "left_option"
{
if(CurrentMode=="none")
{
SetMode("sms");
}
else if(CurrentMode=="menu")
{
ContainersInvisible();
{
case 0:
SetMode("contact");
break;
case 1:
SetMode("sms");
break;
}
}
else if(CurrentMode=="contact")
{
}
else if(CurrentMode=="sms")
{
SetMode("singlesms");
}
else if(CurrentMode=="number")
{
CallNumber(CurrentNumber);
}
else if(CurrentMode=="contact_info")
{
CallContact(CurrentContact);
}
else if(CurrentMode=="incoming_call")
{
SetMode("in_call");
}
}
////////////////////////////////////////////////////////////////////////////////
on "red"
{
if(CurrentMode=="in_call")
{
CallCancelled = true;
SetMode("call_cancelling");
}
else if(CurrentMode=="incoming_call")
{
actor.
Talk("I'd better answer. It could be important.");
}
else if(CurrentMode!="none")
{
ContainersInvisible();
SetMode("none");
}
}
////////////////////////////////////////////////////////////////////////////////
on "green"
{
if(CurrentMode=="number")
{
CallNumber(CurrentNumber);
}
else if(CurrentMode=="contact_info")
{
CallContact(CurrentContact);
}
else if(CurrentMode=="contact")
{
}
else if(CurrentMode=="incoming_call")
{
SetMode("in_call");
}
}
////////////////////////////////////////////////////////////////////////////////
on "down"
{
if(CurrentMode=="none" && NumberItems.Count > 0)
{
SetMode("contact");
return;
}
if(CurrentMode=="singlesms")
{
if(ScrollOffset + NumLines < CurrentSms.NumLines) ScrollOffset = ScrollOffset + 1;
UpdateSms();
return;
}
if(CurrentItems!=null)
{
var Count = CurrentItems.Count;
if(Count==null || Count==0) return;
{
ScrollOffset = 0;
}
if(SelectedItem >= ScrollOffset + NumLines
) ScrollOffset = ScrollOffset +
1;
UpdateItems();
}
}
////////////////////////////////////////////////////////////////////////////////
on "up"
{
if(CurrentMode=="none" && NumberItems.Count > 0)
{
SetMode("contact");
return;
}
if(CurrentMode=="singlesms")
{
if(ScrollOffset > 0) ScrollOffset = ScrollOffset - 1;
UpdateSms();
return;
}
if(CurrentItems!=null)
{
var Count = CurrentItems.Count;
if(Count==null || Count==0) return;
{
ScrollOffset = Count - NumLines;
if(ScrollOffset < 0) ScrollOffset = 0;
}
if(SelectedItem < ScrollOffset
) ScrollOffset = ScrollOffset -
1;
UpdateItems();
}
}
////////////////////////////////////////////////////////////////////////////////
function SetMode(Mode)
{
if(Mode==CurrentMode) return;
CurrentMode = Mode;
ScrollOffset = 0;
CurrentItems = null;
////////////////////////////////////////
if(CurrentMode=="none")
{
MenuOn = false;
SetLine(0, "");
SetLine(1, "");
SetLine(2, "");
SetLine(3, "");
SetLine(4, "");
SetLine(5, "");
SetLine(6, "");
}
////////////////////////////////////////
else if(CurrentMode=="menu")
{
MenuOn = true;
CurrentItems = MenuItems;
UpdateItems();
}
////////////////////////////////////////
else if(CurrentMode=="contact")
{
if(ToInt(NumberItems.
Count)==
0) {
ClearDisplay();
SetLine(2, "No contacts", false, true);
SetMode("menu");
return;
}
CurrentItems = NumberItems;
UpdateItems();
}
////////////////////////////////////////
else if(CurrentMode=="sms")
{
if(ToInt(SmsItems.
Count)==
0) {
ClearDisplay();
SetLine(2, "No messages", false, true);
SetMode("menu");
return;
}
CurrentItems = SmsItems;
UpdateItems();
}
////////////////////////////////////////
else if(CurrentMode=="singlesms")
{
SingleMessageBackground.
Visible =
true;
UpdateSms();
}
////////////////////////////////////////
else if(CurrentMode=="number")
{
ClearDisplay();
CurrentNumber = "";
}
////////////////////////////////////////
else if(CurrentMode=="contact_info")
{
ContactInfoBackground.
Visible =
true;
}
////////////////////////////////////////
else if(CurrentMode=="in_call")
{
ContainersInvisible();
//handles the conversations, based on variables (in this case, Name3Calling, because Name3 is calling us) set in other scripts.
if(Name3Calling==1)
{
IncomingCallBackground.
Visible =
false;
SetLine(3, "Connected...", false, true);
SetLine(4, "Name3", false, true);
actor.
Talk("Hello? Who is this?");
name3.
Talk("Hi, my name is 3, Name 3. Cool name eh?");
actor.
Talk("Yeah it's ok I guess, but not as good as my name....actor!");
name3.
Talk("Yeah, actor is a pretty cool name, but NEVER will it be as cool as mine ok? Anyway, I gotta go. I'm needed in another script.");
actor.
Talk("Ok dude, catch ya later at the Global Variable Conference.");
name3.
Talk("Nah. I aint going to that, I prefer to stay local.");
actor.
Talk("Ummmmmmmmmmmmm k then.");
SetMode("call_cancelling");
ContainersInvisible();
SetMode("none");
//Name3 variable set back to zero, and Name3Calling.OneDone set to "true" so we know Name3's first conversation is over.
Name3Calling = 0;
Name3Calling.OneDone = true;
}
}
////////////////////////////////////////
else if(CurrentMode=="call_cancelling")
{
ClearDisplay();
CallCancellingBackground.
Visible =
true;
SetLine(3, "Disconnecting...", false, true);
}
////////////////////////////////////////
else if(CurrentMode=="incoming_call")
{
IncomingCallBackground.
Visible =
true;
}
}
////////////////////////////////////////////////////////////////////////////////
function UpdateItems()
{
var Count = CurrentItems.Count;
if(Count==null || Count==0) return;
ClearDisplay();
for(var i=ScrollOffset; i<Count; i=i+1)
{
if(i - ScrollOffset >= NumLines) break;
}
}
////////////////////////////////////////////////////////////////////////////////
function UpdateSms()
{
ClearDisplay();
for(var i=ScrollOffset; i<CurrentSms.NumLines; i=i+1)
{
if(i - ScrollOffset >= NumLines) break;
SetLine(i - ScrollOffset, CurrentSms[i]);
}
}
////////////////////////////////////////////////////////////////////////////////
function ClearDisplay()
{
for(var i=0; i<NumLines; i=i+1)
{
SetLine(i, "");
}
}
////////////////////////////////////////////////////////////////////////////////
function SetLine
(LineNum,
Text, Invert,
Center, Right
) {
var Line =
this.
GetControl("Line" +
(LineNum +
1));
if(Line==null) return;
if(Invert==null) Invert = false;
if(Right==null) Right = false;
if(Invert)
{
Line.
SetFont("phone\fonts\arial_display_small_white.font");
}
else
{
Line.
SetFont("phone\fonts\arial_display_small.font");
}
}
////////////////////////////////////////////////////////////////////////////////
{
var Count = MenuItems.Count;
if(Count==null) Count = 0;
MenuItems.Count = Count + 1;
}
////////////////////////////////////////////////////////////////////////////////
function AddNumber
(Name, Number, ID
) {
var Count = NumberItems.Count;
if(Count==null) Count = 0;
NumberItems
[Count
] =
Item;
NumberItems.Count = Count + 1;
}
////////////////////////////////////////////////////////////////////////////////
function AddSms(From, Line1, Line2, Line3, Line4, Line5, Line6, Line7, Line8, Line9)
{
var Count = SmsItems.Count;
if(Count==null) Count = 0;
for(var i=8; i>=0; i=i-1)
{
{
break;
}
}
SmsItems.Count = Count + 1;
}
////////////////////////////////////////////////////////////////////////////////
{
if(KeySound=="*") KeySound = "star";
this.
PlaySound("phone\sfx\" + KeySound +
".ogg");
if(CurrentMode=="none" || CurrentMode=="menu")
{
SetMode("number");
}
if(CurrentMode=="number")
{
if(CurrentNumber.Length>=14) return;
CurrentNumber = CurrentNumber +
Key;
SetLine(6, CurrentNumber, false, false, true);
}
}
////////////////////////////////////////////////////////////////////////////////
function CallNumber(Number)
{
for(var i=0; i<NumberItems.Count; i=i+1)
{
var Item = NumberItems
[i
];
{
return;
}
}
this.CalledNumber = Number;
DoCall(Number);
}
////////////////////////////////////////////////////////////////////////////////
function CallContact(ContactItem)
{
this.CalledNumber = ContactItem.ID;
DoCall
(ContactItem.
Text);
}
////////////////////////////////////////////////////////////////////////////////
{
ClearDisplay();
SetMode("in_call");
SetLine(2, "Calling...", false, true);
SetLine
(3,
Name,
false,
true);
while(CallCancelled==false && RingCounter<5)
{
RingCounter = RingCounter + 1;
}
if(CallCancelled==true)
{
CallCancelled = false;
RingCounter = 0;
ContainersInvisible();
SetMode("none");
}
else
{
}
}
////////////////////////////////////////////////////////////////////////////////
function ContainersInvisible() //easy way to set all entity containers to invisible
{
ClearDisplay();
ContactsBackground.
Visible =
false;
MessagesBackground.
Visible =
false;
SingleMessageBackground.
Visible =
false;
ContactInfoBackground.
Visible =
false;
IncomingCallBackground.
Visible =
false;
CallCancellingBackground.
Visible =
false;
}
////////////////////////////////////////////////////////////////////////////////
function DisplayContactInfo(ContactItem)
{
ClearDisplay();
SetMode("contact_info");
SetLine
(5, ContactItem.
Text,
false,
false,
true);
SetLine(6, ContactItem.Number, false, false, true);
}
////////////////////////////////////////////////////////////////////////////////
on "close"
{
}