Skip to content

Commit e84f1dd

Browse files
committed
1.4.0
new features: arrow keys in chats scroll attempting to chat with BugReport suggests to use github
1 parent 592380c commit e84f1dd

4 files changed

Lines changed: 78 additions & 37 deletions

File tree

Additions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public void StartListening(string ChatRoom) {
338338

339339
while (true) {
340340
try {
341-
ChatContent = File.ReadLines(ChatRoom+".txt").ToArray();
341+
ChatContent = File.ReadLines(ChatRoom).ToArray();
342342
} catch {
343343
Console.Write("");
344344
}

User.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,10 @@ public string Read_Messages_FileName(string TargetChat) {
188188
} else if (File.Exists(@"chats\" + ChatNameB + ".txt")) {
189189
return ChatNameB;
190190
} else {
191+
Console.WriteLine(ChatNameA);
192+
Console.WriteLine(ChatNameB);
191193
Console.WriteLine("That Chat Does Not Exist");
192-
while (true) {
193-
Console.Read();
194-
}
194+
throw new InvalidOperationException("That Chat Does Not Exist");
195195
}
196196
}
197197

@@ -388,7 +388,7 @@ public static void Pointer(string[] Content, Tuple<int, int> BoardDimensions, in
388388
}
389389

390390
}
391-
public static void Content(string[] Content, Tuple<int, int> BoardDimensions, string TypedText = "", bool IfChat = false, string Username = "TEMPVALUE") {
391+
public static void Content(string[] Content, Tuple<int, int> BoardDimensions, string TypedText = "", bool IfChat = false, string Username = "TEMPVALUE", int Pointer = 0) {
392392
Board Board = new Board(BoardDimensions.Item1, BoardDimensions.Item2);
393393
Board = Square.Create(new Square(Board.Width,Board.Height,Tuple.Create(0,0)), Board);
394394

@@ -420,8 +420,9 @@ public static void Content(string[] Content, Tuple<int, int> BoardDimensions, st
420420
int VerticalBorder = 5;
421421
Board = Line.Create(new Line(Tuple.Create(0, Board.Height-3),Tuple.Create(Board.Width, Board.Height-3)), Board);
422422
Board = Text.Create(new Text(Tuple.Create(1,Board.Height-2), "Chatting With: "+Username), Board);
423-
for (int i = 0; (i < BoardDimensions.Item2 - VerticalBorder) && (i < DisplayedMessagesArray.Length); i++) {
424-
Board = Text.Create(new Text(Tuple.Create(2,2+i), DisplayedMessagesArray[i]), Board);
423+
424+
for (int i = 0; (i < BoardDimensions.Item2 - VerticalBorder) && (i < DisplayedMessagesArray.Length) && (DisplayedMessagesArray.Length > i+Pointer); i++) {
425+
Board = Text.Create(new Text(Tuple.Create(2,2+i), DisplayedMessagesArray[i+Pointer]), Board);
425426
}
426427
} else {
427428
for (int i = 0; i < Content.Length; i++) {

Version and Change Notes.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
1.4.0
2+
new features:
3+
arrow keys in chats scroll
4+
attempting to chat with BugReport suggests to use github
5+
bugfixes:
6+
filter list now filters capital letter strings too
7+
creating a new chat and already created chat lists are now sorted
8+
1.3.0
9+
new features:
10+
the ESC now goes back
11+
1.2.0
12+
new features:
13+
public chat
14+
found bugs:
15+
will freeze if 2 users send message at same time, ends when one closes the program
16+
1.1.1
17+
bugfixes:
18+
rendering is faster
19+
it no longer starts eating inputs after entering settings
20+
ENCRYPTION METHOD WAS CHANGED

program.cs

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void Main(string[] args)
6565

6666
Tuple = MenuLoop(Content, BoardDimensions, true);
6767

68-
if (BadWords.BadWords.list.Any(Tuple.Item2.Contains)) {
68+
if (BadWords.BadWords.list.Any(Tuple.Item2.ToLower().Contains)) {
6969
Console.WriteLine("bad Word Found, Redo Step (wait a sec)");
7070
System.Threading.Thread.Sleep(3000);
7171
goto BadNameUsername;
@@ -149,6 +149,7 @@ public static void PublicChat(User.User CurrentUser) {
149149
bool ChooseChatLoop = true;
150150

151151
string[] var = Admin.Read.Chats.Public();
152+
Array.Sort(var);
152153

153154
int Multiplyer = 0;
154155
int Step = BoardDimensions.Item2-6;
@@ -179,6 +180,7 @@ public static void PublicChat(User.User CurrentUser) {
179180
}
180181

181182
var = Admin.Read.Chats.Public();
183+
Array.Sort(var);
182184
Multiplyer = 0;
183185

184186
while (!TextListener.GetESCPressed() && (Tuple.Item1 == Step-1 || Tuple.Item1 == Step || Tuple.Item1 == Step+1)) {
@@ -219,12 +221,14 @@ public static void PublicChatLoop(string SelectedChat, User.User CurrentUser) {
219221
Tuple<int,int> BoardDimensions = CurrentUser.Read_User_BoardSettings();
220222
DMSExtras.DMSExtras.TextListener TextListener = new DMSExtras.DMSExtras.TextListener();
221223
DMSExtras.DMSExtras.ChatListener ChatListener = new DMSExtras.DMSExtras.ChatListener();
224+
bool UpdateBoard = false;
225+
int Pointer = 0;
222226

223227
string TypedText = " ";
224228

225229
Thread threadChat = new Thread(() =>
226230
{
227-
ChatListener.StartListening(@"chatsPublic\"+SelectedChat);
231+
ChatListener.StartListening(@"chatsPublic\"+SelectedChat+".txt");
228232
});
229233

230234
threadChat.Start();
@@ -246,7 +250,7 @@ public static void PublicChatLoop(string SelectedChat, User.User CurrentUser) {
246250

247251
if (TextListener.GetEnterPressed() && !string.IsNullOrEmpty(TypedText)) {
248252

249-
if (BadWords.BadWords.list.Any(TypedText.Contains)) {
253+
if (BadWords.BadWords.list.Any(TypedText.ToLower().Contains)) {
250254
Console.WriteLine("bad Word Found, Message not Sent");
251255
System.Threading.Thread.Sleep(1000);
252256
TextListener.StopListening();
@@ -262,33 +266,36 @@ public static void PublicChatLoop(string SelectedChat, User.User CurrentUser) {
262266

263267
TextListener.StopListening();
264268
TextListener.SetTypedText("");
269+
TextListener.SetPointer(0);
265270
TextListener.SetEnterPressed(false);
266271
TextListener.StartListening();
267272
}
268273
}
269274

270275
if (TypedText != TextListener.GetTypedText()) {
271-
272-
// Console.WriteLine("text start");
273-
274276
TypedText = TextListener.GetTypedText();
277+
UpdateBoard = true;
278+
}
275279

276-
User.User.Display.Content(ChatMessages,BoardDimensions,TypedText, true, SelectedChat);
277-
// Console.WriteLine("text end");
278-
280+
if (Pointer != TextListener.GetPointer()) {
281+
if (TextListener.GetPointer() < 0) {
282+
TextListener.StopListening();
283+
TextListener.SetPointer(0);
284+
TextListener.StartListening();
285+
}
286+
UpdateBoard = true;
287+
Pointer = TextListener.GetPointer();
279288
}
280289

281290
if (!ChatMessages.SequenceEqual(ChatListener.GetChatContent())) {
282-
283-
// Console.WriteLine("chat start");
284-
285291
ChatMessages = ChatListener.GetChatContent();
292+
UpdateBoard = true;
293+
}
286294

287-
User.User.Display.Content(ChatMessages,BoardDimensions,TypedText, true, SelectedChat);
288-
// Console.WriteLine("chat end");
289-
295+
if (UpdateBoard) {
296+
User.User.Display.Content(ChatMessages,BoardDimensions,TypedText, true, SelectedChat, Pointer);
297+
UpdateBoard = false;
290298
}
291-
// Console.WriteLine("end");
292299
}
293300

294301

@@ -312,6 +319,7 @@ public static void PrivateChat(User.User CurrentUser) {
312319
bool ChooseChatLoop = true;
313320

314321
string[] var = CurrentUser.Read_Chats_Allowed(@"chats\");
322+
Array.Sort(var);
315323

316324
int Multiplyer = 0;
317325
int Step = BoardDimensions.Item2-6;
@@ -342,6 +350,7 @@ public static void PrivateChat(User.User CurrentUser) {
342350
}
343351

344352
var = Admin.Read.Users.All();
353+
Array.Sort(var);
345354
Multiplyer = 0;
346355

347356
while (!TextListener.GetESCPressed() && (Tuple.Item1 == Step-1 || Tuple.Item1 == Step || Tuple.Item1 == Step+1)) {
@@ -369,6 +378,11 @@ public static void PrivateChat(User.User CurrentUser) {
369378
}
370379
}
371380
if (!TextListener.GetESCPressed()) {
381+
if (DisplayedChats[Tuple.Item1] == "BugReport") {
382+
Console.WriteLine("submit bugs here, https://github.com/hacktheegg/EncryptedDMSystem/issues/new/choose");
383+
Console.ReadKey();
384+
Console.ReadKey();
385+
}
372386
string SelectedChat = DisplayedChats[Tuple.Item1];
373387
string OtherUser = SelectedChat;
374388
SelectedChat = CurrentUser.Read_Messages_FileName(SelectedChat);
@@ -429,12 +443,14 @@ public static Tuple<int, string> MenuLoop(string[] Content, Tuple<int,int> Board
429443
public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDimensions, User.User CurrentUser, Tuple<string, string> SymmetricKey, string OtherUser) {
430444
DMSExtras.DMSExtras.TextListener TextListener = new DMSExtras.DMSExtras.TextListener();
431445
DMSExtras.DMSExtras.ChatListener ChatListener = new DMSExtras.DMSExtras.ChatListener();
446+
bool UpdateBoard = false;
447+
int Pointer = 0;
432448

433449
string TypedText = " ";
434450

435451
Thread threadChat = new Thread(() =>
436452
{
437-
ChatListener.StartListening(@"chats\"+SelectedChat);
453+
ChatListener.StartListening(@"chats\"+SelectedChat+".txt");
438454
});
439455

440456
threadChat.Start();
@@ -458,7 +474,7 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
458474

459475
if (TextListener.GetEnterPressed() && !string.IsNullOrEmpty(TypedText)) {
460476

461-
if (BadWords.BadWords.list.Any(TypedText.Contains)) {
477+
if (BadWords.BadWords.list.Any(TypedText.ToLower().Contains)) {
462478
Console.WriteLine("bad Word Found, Message not Sent");
463479
System.Threading.Thread.Sleep(1000);
464480
TextListener.StopListening();
@@ -469,34 +485,38 @@ public static void PrivateChatLoop(string SelectedChat, Tuple<int, int> BoardDim
469485

470486
TextListener.StopListening();
471487
TextListener.SetTypedText("");
488+
TextListener.SetPointer(0);
472489
TextListener.SetEnterPressed(false);
473490
TextListener.StartListening();
474491
}
475492
}
476493

477494
if (TypedText != TextListener.GetTypedText()) {
478-
479-
// Console.WriteLine("text start");
480-
481495
TypedText = TextListener.GetTypedText();
496+
UpdateBoard = true;
497+
}
482498

483-
User.User.Display.Content(DecryptedMessages,BoardDimensions,TypedText, true, OtherUser);
484-
// Console.WriteLine("text end");
485-
499+
if (Pointer != TextListener.GetPointer()) {
500+
if (TextListener.GetPointer() < 0) {
501+
TextListener.StopListening();
502+
TextListener.SetPointer(0);
503+
TextListener.StartListening();
504+
}
505+
UpdateBoard = true;
506+
Pointer = TextListener.GetPointer();
486507
}
487508

488509
if (!ChatMessages.SequenceEqual(ChatListener.GetChatContent())) {
489-
490-
// Console.WriteLine("chat start");
491-
492510
ChatMessages = ChatListener.GetChatContent();
493511
DecryptedMessages = CurrentUser.Read_Messages_Chat(ChatMessages);
512+
UpdateBoard = true;
494513

495-
User.User.Display.Content(DecryptedMessages,BoardDimensions,TypedText, true, OtherUser);
496-
// Console.WriteLine("chat end");
514+
}
497515

516+
if (UpdateBoard) {
517+
User.User.Display.Content(DecryptedMessages,BoardDimensions,TypedText, true, OtherUser, Pointer);
518+
UpdateBoard = false;
498519
}
499-
// Console.WriteLine("end");
500520
}
501521
TextListener.StopListening();
502522
}

0 commit comments

Comments
 (0)