// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl 0x1c(%rdi), %r14d
movl $0x1, %ebp
cmpl $-0x1, %r14d
je 0xb5a0
movq %rdi, %rbx
leaq 0x50e8(%rip), %r15      # 0x10390
movq (%r15), %rdi
leaq 0xecc(%rip), %rsi       # 0xc17e
callq 0x3130
movq %rax, %rdi
callq 0x34e0
cmpl %eax, %r14d
jae 0xb434
leaq 0x50b1(%rip), %r13      # 0x10380
movq (%r13), %rdi
leaq 0x16b4(%rip), %rsi      # 0xc98e
callq 0xa57c
movq (%r13), %r14
movq (%r15), %rdi
leaq 0xe91(%rip), %rsi       # 0xc17e
callq 0x3130
movl 0x1c(%rbx), %esi
movq %rax, %rdi
callq 0x3300
leaq 0x78(%rsp), %r12
movq %r12, %rdi
movq %rax, %rsi
callq 0x3580
movq %r14, %rdi
movq %r12, %rsi
callq 0xa5ca
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb339
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
movq (%r13), %rdi
leaq 0xf7f(%rip), %rsi       # 0xc2c3
callq 0xa57c
movq (%r15), %rdi
leaq 0xe2b(%rip), %rsi       # 0xc17e
callq 0x3130
movl 0x1c(%rbx), %esi
movq %rax, %rdi
callq 0x3300
movq %rsp, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x3580
movq (%r14), %rdi
callq 0xa3a1
movq %rax, 0x28(%rsp)
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb399
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x32d0
movq %rsp, %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x3160
leaq 0xdd2(%rip), %r12       # 0xc17e
leaq 0x30(%rsp), %r13
leaq 0x50(%rsp), %r14
movq (%r15), %rdi
movq %r12, %rsi
callq 0x3130
movq %rax, %rdi
callq 0x34e0
cmpl %eax, %ebp
jae 0xb4d3
cmpl 0x1c(%rbx), %ebp
je 0xb430
movq (%r15), %rdi
movq %r12, %rsi
callq 0x3130
movq %rax, %rdi
movl %ebp, %esi
callq 0x3300
movq %r13, %rdi
movq %rax, %rsi
callq 0x3580
movq %r14, %rdi
movq %r13, %rsi
callq 0x34c0
movq %rsp, %rdi
movq %r14, %rsi
callq 0x33e0
movq %r14, %rdi
callq 0x31b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb430
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
incl %ebp
jmp 0xb3b6
movl 0x1c(%rbx), %r14d
movq (%r15), %rdi
leaq 0xd3c(%rip), %rsi       # 0xc17e
callq 0x3130
movq %rax, %rdi
callq 0x34e0
cmpl %eax, %r14d
jne 0xb5a0
movq (%r15), %rdi
leaq 0xe9e(%rip), %rsi       # 0xc300
callq 0x3130
movq %rax, %r14
leaq 0x50(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x3200
movq %r14, %rdi
movq %r12, %rsi
callq 0x33d0
movzbl %al, %esi
movq %rsp, %rdi
callq 0x3200
movq (%r15), %rdi
leaq 0xe67(%rip), %rsi       # 0xc300
callq 0x3130
movq %rsp, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x3380
movq %r14, %rdi
callq 0x31b0
leaq 0x50(%rsp), %rdi
callq 0x31b0
movq (%r15), %rdi
callq 0xa8d8
movq %rbx, %rdi
callq 0xaf3c
jmp 0xb5a0
movq (%r15), %rdi
leaq 0xca1(%rip), %rsi       # 0xc17e
callq 0x3130
movq %rsp, %rsi
movq %rax, %rdi
callq 0x3410
movq (%r15), %rdi
callq 0xa8d8
movl $0xffffffff, 0x1c(%rbx) # imm = 0xFFFFFFFF
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
movl 0x10(%rbx), %ecx
movq %rbx, %rdi
callq 0xb1c2
movq %rbx, %rdi
callq 0xaf3c
movl $0x18, %edi
callq 0x32c0
movq 0x28(%rsp), %r15
movq %rax, %r14
leaq 0x4de2(%rip), %rbx      # 0x10310
movq 0x8(%rbx), %rax
subq (%rbx), %rax
shrq $0x3, %rax
leal (%rax,%rax,2), %edx
incl %edx
movq 0x4a73(%rip), %rax      # 0xffb8
movl (%rax), %ecx
movq %r14, %rdi
xorl %esi, %esi
movl $0x3, %r8d
callq 0x959e
movq %r14, 0x50(%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0xb570
movq %r14, (%rsi)
addq $0x8, 0x8(%rbx)
jmp 0xb581
leaq 0x4d99(%rip), %rdi      # 0x10310
leaq 0x50(%rsp), %rdx
callq 0x7d62
movq %r15, %rdi
callq 0x9fd8
movq 0x50(%rsp), %rsi
movq %r15, %rdi
callq 0x9fc0
movq %rsp, %rdi
callq 0x31b0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %rsp, %rdi
callq 0x31b0
jmp 0xb5e9
movq %rax, %rbx
movl $0x18, %esi
movq %r14, %rdi
jmp 0xb643
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb657
movq 0x10(%rsp), %rsi
jmp 0xb60c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0xb652
movq %rax, %rbx
leaq 0x88(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb657
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0xb657
jmp 0xb64c
jmp 0xb64c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x31b0
jmp 0xb62c
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb64f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x32d0
jmp 0xb64f
jmp 0xb64c
movq %rax, %rbx
movq %rsp, %rdi
callq 0x31b0
movq %rbx, %rdi
callq 0x3550