// File: Stygain[P]bandwidth-monitor/src/settingsWindow.cpp
// Function: SettingsWindow::Selected()
SettingsWindowSelection SettingsWindow::Selected()
{
	if (this->activeItem != -1)
	{
		if (this->activeItem < settings->root["hiddenInterfaces"].size())
		{
			// Unhide this interface
			logger->Log("Selected interface: ");
			logger->Log(settings->root["hiddenInterfaces"][this->activeItem].asString());
			logger->Log("\n");

			Interface *toUnhide = getMatchingInterface(settings->root["hiddenInterfaces"][this->activeItem].asString().c_str());

			Json::Value newArr;
			for (int i = 0; i < settings->root["hiddenInterfaces"].size(); i++)
			{
				if (i != this->activeItem)
				{
					newArr.append(settings->root["hiddenInterfaces"][i].asString());
				}
			}
			settings->root["hiddenInterfaces"] = newArr;
			settings->SaveSettings();
			
			// Resize window
			this->activeItem = -1;
			this->Resize(this->placementX, this->placementY, this->width);
			this->Update();

			extern std::vector<InterfaceRow *> interfaceRows;
			extern std::vector<Interface *> interfaces;

			InterfaceRow *interfaceRow = new InterfaceRow(0, (interfaceRows.size() * 3) + 1, COLS, 3);
			interfaceRows.push_back(interfaceRow);
			toUnhide->AddToUI();
			toUnhide->setInterfaceRow(interfaceRow);

			// Return a value so that in main we create an interface row for the unhidden interface
			return CREATE_NEW_INTERFACE;
		}
		else if (this->activeItem == settings->root["hiddenInterfaces"].size())
		{
			settings->root["zeroOnStart"] = settings->root["zeroOnStart"] == 0 ? 1 : 0;
			settings->SaveSettings();

			this->Update();
		}
	}

	return NO_ACTION;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
cmpl $-0x1, 0x1c(%rax)
je 0x15522
movq -0x140(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x144(%rbp)
leaq 0x940d(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0x1149(%rip), %rsi      # 0x1611e
callq 0x3140
movq %rax, %rdi
callq 0x3550
movl %eax, %ecx
movl -0x144(%rbp), %eax
cmpl %ecx, %eax
jae 0x153de
leaq 0x93cf(%rip), %rax      # 0x1e3c8
movq %rax, -0x160(%rbp)
movq (%rax), %rdi
leaq 0x18f8(%rip), %rsi      # 0x16902
callq 0x13910
movq -0x160(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x158(%rbp)
leaq 0x93b1(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0x10ed(%rip), %rsi      # 0x1611e
callq 0x3140
movq %rax, %rdi
movq -0x140(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x3380
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x3600
movq -0x158(%rbp), %rdi
movq -0x150(%rbp), %rsi
callq 0x13940
jmp 0x15070
leaq -0x30(%rbp), %rdi
callq 0x3250
leaq 0x9348(%rip), %rax      # 0x1e3c8
movq (%rax), %rdi
leaq 0x11d9(%rip), %rsi      # 0x16263
callq 0x13910
leaq 0x9342(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0x107e(%rip), %rsi      # 0x1611e
callq 0x3140
movq %rax, %rdi
movq -0x140(%rbp), %rax
movl 0x1c(%rax), %esi
callq 0x3380
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x3600
movq -0x170(%rbp), %rdi
callq 0x3160
movq %rax, %rdi
callq 0x13620
movq %rax, -0x168(%rbp)
jmp 0x150e7
leaq -0x68(%rbp), %rdi
callq 0x3250
movq -0x168(%rbp), %rax
movq %rax, -0x48(%rbp)
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
callq 0x3180
movl $0x0, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x17c(%rbp)
leaq 0x92b2(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0xfee(%rip), %rsi       # 0x1611e
callq 0x3140
movq %rax, -0x178(%rbp)
jmp 0x1513e
movq -0x178(%rbp), %rdi
callq 0x3550
movl %eax, -0x180(%rbp)
jmp 0x15152
movl -0x17c(%rbp), %eax
movl -0x180(%rbp), %ecx
cmpl %ecx, %eax
jae 0x152a1
movq -0x140(%rbp), %rcx
movl -0x94(%rbp), %eax
cmpl 0x1c(%rcx), %eax
je 0x1528b
leaq 0x9255(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0xf91(%rip), %rsi       # 0x1611e
callq 0x3140
movq %rax, -0x188(%rbp)
jmp 0x1519b
movq -0x188(%rbp), %rdi
movl -0x94(%rbp), %esi
callq 0x3380
movq %rax, -0x190(%rbp)
jmp 0x151b6
movq -0x190(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x3600
jmp 0x151cb
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3530
jmp 0x151e0
leaq -0x90(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3450
jmp 0x151f5
leaq -0xc0(%rbp), %rdi
callq 0x31d0
leaq -0xe0(%rbp), %rdi
callq 0x3250
jmp 0x1528b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3250
jmp 0x15535
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3250
jmp 0x15535
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x153cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x1527a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x31d0
leaq -0xe0(%rbp), %rdi
callq 0x3250
jmp 0x153cd
jmp 0x1528d
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x15113
leaq 0x9130(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0xe6c(%rip), %rsi       # 0x1611e
callq 0x3140
movq %rax, -0x198(%rbp)
jmp 0x152c0
movq -0x198(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3480
jmp 0x152d5
leaq 0x90fc(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
callq 0x13ef0
jmp 0x152e6
movq -0x140(%rbp), %rdi
movl $0xffffffff, 0x1c(%rdi) # imm = 0xFFFFFFFF
movl 0x8(%rdi), %esi
movl 0xc(%rdi), %edx
movl 0x10(%rdi), %ecx
callq 0x14e20
jmp 0x15304
movq -0x140(%rbp), %rdi
callq 0x14a90
jmp 0x15312
movl $0x18, %edi
callq 0x3320
movq %rax, -0x1a0(%rbp)
jmp 0x15325
leaq 0x902c(%rip), %rdi      # 0x1e358
callq 0x9f40
movq -0x1a0(%rbp), %rdi
movl %eax, %ecx
movl %ecx, %eax
leal 0x1(%rax,%rax,2), %edx
movq 0x8c79(%rip), %rax      # 0x1dfc0
movl (%rax), %ecx
xorl %esi, %esi
movl $0x3, %r8d
callq 0x123f0
jmp 0x15358
movq -0x1a0(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq 0x8feb(%rip), %rdi      # 0x1e358
leaq -0xe8(%rbp), %rsi
callq 0x9cb0
jmp 0x1537b
movq -0x48(%rbp), %rdi
callq 0x130a0
jmp 0x15386
movq -0x48(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x13040
jmp 0x15398
movl $0x0, -0x4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x31d0
jmp 0x15529
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x18, %esi
callq 0x3330
leaq -0x90(%rbp), %rdi
callq 0x31d0
jmp 0x15535
movq -0x140(%rbp), %rax
movl 0x1c(%rax), %eax
movl %eax, -0x1a4(%rbp)
leaq 0x8fe3(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0xd1f(%rip), %rsi       # 0x1611e
callq 0x3140
movq %rax, %rdi
callq 0x3550
movl %eax, %ecx
movl -0x1a4(%rbp), %eax
cmpl %ecx, %eax
jne 0x1551e
leaq 0x8fb5(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0xe99(%rip), %rsi       # 0x162c6
callq 0x3140
movq %rax, -0x1b8(%rbp)
leaq -0x138(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
xorl %esi, %esi
callq 0x3230
movq -0x1b8(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
callq 0x3440
movb %al, -0x1a5(%rbp)
jmp 0x15469
movb -0x1a5(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x110(%rbp), %rdi
callq 0x3230
jmp 0x15483
leaq 0x8f4e(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
leaq 0xe32(%rip), %rsi       # 0x162c6
callq 0x3140
movq %rax, -0x1c0(%rbp)
jmp 0x154a2
movq -0x1c0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x33f0
leaq -0x110(%rbp), %rdi
callq 0x31d0
leaq -0x138(%rbp), %rdi
callq 0x31d0
leaq 0x8f04(%rip), %rax      # 0x1e3d8
movq (%rax), %rdi
callq 0x13ef0
movq -0x140(%rbp), %rdi
callq 0x14a90
jmp 0x1551e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x15510
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x31d0
leaq -0x138(%rbp), %rdi
callq 0x31d0
jmp 0x15535
jmp 0x15520
jmp 0x15522
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x35c0